Cheat sheets

curl cheat sheet: GET, POST JSON, headers, save and time

The curl commands you keep looking up: send JSON, add headers, save the output and time a request.

Handy? Press ⌘ DCtrl + D to bookmark this page for next time.

Fill these in once
  1. GET a page or API
    Terminal
    curl https://api.example.com/users
  2. POST JSON
    Terminal
    curl -X POST -H "Content-Type: application/json" -d '{"name":"Ada"}' https://api.example.com/users
  3. Send a header (for example a token)
    Terminal
    curl -H "Authorization: Bearer your-token" https://api.example.com/users
  4. Save the response to a file
    Terminal
    curl -o response.json https://api.example.com/users
  5. Show only the response headers
    Terminal
    curl -I https://api.example.com/users
  6. Follow redirects
    Terminal
    curl -L https://api.example.com/users
  7. Time the request
    Terminal
    curl -s -o /dev/null -w "total: %{time_total}s\n" https://api.example.com/users
  1. GET a page or API
    Terminal · Ubuntu / Debian
    curl https://api.example.com/users
  2. POST JSON
    Terminal · Ubuntu / Debian
    curl -X POST -H "Content-Type: application/json" -d '{"name":"Ada"}' https://api.example.com/users
  3. Send a header (for example a token)
    Terminal · Ubuntu / Debian
    curl -H "Authorization: Bearer your-token" https://api.example.com/users
  4. Save the response to a file
    Terminal · Ubuntu / Debian
    curl -o response.json https://api.example.com/users
  5. Show only the response headers
    Terminal · Ubuntu / Debian
    curl -I https://api.example.com/users
  6. Follow redirects
    Terminal · Ubuntu / Debian
    curl -L https://api.example.com/users
  7. Time the request
    Terminal · Ubuntu / Debian
    curl -s -o /dev/null -w "total: %{time_total}s\n" https://api.example.com/users
  1. GET a page or API
    PowerShell
    curl.exe https://api.example.com/users
  2. POST JSON
    PowerShell
    curl.exe -X POST -H "Content-Type: application/json" -d "@data.json" https://api.example.com/users
  3. Send a header (for example a token)
    PowerShell
    curl.exe -H "Authorization: Bearer your-token" https://api.example.com/users
  4. Save the response to a file
    PowerShell
    curl.exe -o response.json https://api.example.com/users
  5. Show only the response headers
    PowerShell
    curl.exe -I https://api.example.com/users
  6. Follow redirects
    PowerShell
    curl.exe -L https://api.example.com/users
  7. Time the request
    PowerShell
    curl.exe -s -o NUL -w "total: %{time_total}s\n" https://api.example.com/users