curl -H 'Accept: application/json' https://api.example.com/v1/itemsA standard API request pattern.
HTTP methods, auth, JSON APIs, headers, caching, compression, and response inspection with curl.
GET, POST, PUT, PATCH, DELETE, OPTIONS and common REST patterns.
curl -H 'Accept: application/json' https://api.example.com/v1/itemsA standard API request pattern.
curl -X POST https://api.example.com/v1/items -H 'Content-Type: application/json' -d '{"name":"demo"}'Set `Content-Type: application/json` when posting JSON bodies.
curl -X PUT https://api.example.com/v1/items/123 -H 'Content-Type: application/json' -d '{"name":"updated"}'PUT is commonly used for full replacement of a resource.
curl -X PATCH https://api.example.com/v1/items/123 -H 'Content-Type: application/json' -d '{"status":"archived"}'PATCH is used for partial updates.
curl -X DELETE https://api.example.com/v1/items/123Common REST delete pattern.
curl -X OPTIONS -i https://api.example.com/v1/itemsHelpful for CORS and API debugging.
curl -X TRACE -i https://example.comTRACE is often disabled for security reasons.
curl -X POST https://api.example.com/import -H 'Content-Type: application/xml' --data-binary @payload.xmlNot all APIs use JSON; curl can send any content type.
Basic, bearer, API keys, cookies, mTLS, and AWS SigV4.
curl -u 'user:password' https://example.com/protected`-u` sends credentials for Basic auth or similar schemes.
curl -H 'Authorization: Bearer TOKEN' https://api.example.com/meA common pattern for REST and GraphQL APIs.
curl -H 'x-api-key: YOUR_API_KEY' https://api.example.com/dataMany APIs require custom key headers.
curl 'https://api.example.com/data?api_key=YOUR_API_KEY'Some APIs still accept query-string keys, though headers are often preferred.
curl --cert client.crt --key client.key https://mtls.example.comUse mTLS when the server requires client certificates.
curl --cacert ca.pem https://internal.example.comUseful for private PKI or local development environments.
curl -k https://selfsigned.example.com`-k` / `--insecure` is convenient in dev, but avoid it in production workflows.
curl --aws-sigv4 'aws:amz:us-east-1:execute-api' --user 'AKIA...:SECRET' https://abc123.execute-api.us-east-1.amazonaws.com/prod/itemscurl includes AWS Signature Version 4 support.
Headers, redirects, cache data, compression, and conditional requests.
curl --compressed https://example.comcurl can request and decode compressed responses automatically.
curl --etag-save etag.txt -O https://example.com/data.jsonUseful for polling resources efficiently.
curl --etag-compare etag.txt -O https://example.com/data.jsonIf the content is unchanged the server can return `304 Not Modified`.
curl -z local-copy.txt -O https://example.com/local-copy.txt`-z` uses time conditions such as If-Modified-Since.
curl -D headers.txt -o body.html https://example.comThis keeps response body and headers in separate files.
curl -v https://example.com`-v` is the first switch to reach for when debugging.
curl --trace-ascii trace.txt https://example.com`--trace-ascii` is more detailed than `-v` and script-friendly.
curl https://example.com --next -I https://api.example.com`--next` lets one command perform multiple logically separate requests.