1 min read

curl cheat sheet for API testing


curl essentials

POST JSON:

curl_post.sh
curl -X POST https://api.example.com/items \
  -H "Content-Type: application/json" \
  -d '{"name": "test", "value": 42}'

With auth header:

curl_auth.sh
curl -H "Authorization: Bearer $TOKEN" https://api.example.com/me

Follow redirects and show response headers:

curl_verbose.sh
curl -L -i https://example.com/redirect

Time the request:

curl_time.sh
curl -o /dev/null -s -w "HTTP %{http_code} in %{time_total}s\n" https://api.example.com/health

Download with progress:

curl_download.sh
curl -# -O https://example.com/large-file.zip