Basic Options
- curl URLSimple GET
- -X METHODHTTP method
- -vVerbose output
- -sSilent mode
- -iInclude headers
- -IHeaders only
- -LFollow redirects
HTTP Methods
- -X GETGET (default)
- -X POSTPOST request
- -X PUTPUT request
- -X PATCHPATCH request
- -X DELETEDELETE request
- -X HEADHEAD request
Headers
- -H "Key: Value"Add header
- -H "Content-Type: ..."Content type
- -H "Accept: ..."Accept type
- -A "User-Agent"User agent
- -e "Referer"Referer header
Authentication
- -u user:passBasic auth
- -H "Authorization: Bearer TOKEN"Bearer token
- --digestDigest auth
- --ntlmNTLM auth
- -nUse .netrc
Sending Data
# POST with form data
curl -X POST -d "name=John&age=30" http://api.example.com/users
# POST with JSON
curl -X POST -H "Content-Type: application/json" \
-d '{"name":"John","age":30}' http://api.example.com/users
# POST JSON from file
curl -X POST -H "Content-Type: application/json" \
-d @data.json http://api.example.com/users
# Upload file (multipart)
curl -X POST -F "file=@photo.jpg" -F "name=profile" http://api.com/upload
Output Options
# Save to file
curl -o output.html http://example.com
curl -O http://example.com/file.zip # Use remote filename
# Show only status code
curl -s -o /dev/null -w "%{http_code}" http://example.com
# Show timing info
curl -w "Time: %{time_total}s\n" http://example.com
# Pretty print JSON (with jq)
curl -s http://api.com/data | jq .
SSL/TLS Options
- -kSkip SSL verify
- --cacert fileCA certificate
- --cert fileClient cert
- --key filePrivate key
- --tlsv1.2Force TLS 1.2
Timeouts & Retry
- --connect-timeout 10Connect timeout
- -m 30Max time (total)
- --retry 3Retry count
- --retry-delay 5Retry delay (sec)
Common Examples
# GET with auth header
curl -H "Authorization: Bearer $TOKEN" http://api.example.com/users
# POST JSON with verbose
curl -v -X POST -H "Content-Type: application/json" \
-d '{"key":"value"}' http://api.com/endpoint
# Download with progress bar
curl -# -O http://example.com/largefile.zip
# Test API endpoint
curl -s -w "\nHTTP: %{http_code} | Time: %{time_total}s\n" http://api.com/health
Cookies
- -b "name=value"Send cookie
- -b cookies.txtRead cookies
- -c cookies.txtSave cookies
- -b "" -c ""Cookie jar
Proxy Options
- -x proxy:portUse proxy
- -U user:passProxy auth
- --socks5 host:portSOCKS5 proxy
- --noproxy "*"Bypass proxy