curl Quick Reference
Talk to any HTTP API from the terminal — headers, bodies, auth, downloads, and the flags that make debugging painless.
Requests
- GET (default)
curl https://api.example.com/users- POST JSON
curl -X POST -H "Content-Type: application/json" -d '{"a":1}' URL- Data from file
curl -d @body.json URL- Form / upload
curl -F file=@photo.png URL- Method
-X PUT/-X DELETE/-X PATCH
Headers & auth
- Add header
-H "Authorization: Bearer $TOKEN"- Basic auth
-u user:pass- Send cookies
-b "session=abc"· save:-c jar.txt
Inspect & debug
- Show response headers
curl -i URL(headers + body) ·-Iheaders only- Verbose (see request)
curl -v URL— full handshake & headers- Just the status code
curl -s -o /dev/null -w "%{http_code}" URL- Timing breakdown
curl -w "@curl-format.txt" -o /dev/null -s URL(DNS/connect/TTFB)
Behavior
- Follow redirects
-L- Silent / show errors
-sS— quiet but still print errors- Download to file
-O(remote name) ·-o out.zip- Fail on HTTP error
-f— non-2xx exits non-zero (for scripts)- Retry
--retry 3 --retry-delay 2