Test REST APIs from the terminal: CRUD with JSON, auth (Bearer, Basic, API key, cookies, mTLS), timing breakdown with -w, calling an endpoint 100× sequentially or in parallel with status tallies and p50/p95/p99, rate-limit checks and CI assertions.
| Flag | Meaning |
|---|---|
-X METHOD | HTTP method (GET default; POST implied by -d) |
-H "K: V" | Add a header |
-d / --json | Body (--json sets Content-Type + Accept, curl ≥ 7.82) |
-sS | Silent but still show errors |
-i / -I | Include response headers / HEAD only |
-v | Verbose request/response |
-o FILE / -O | Save body / use remote filename |
-w FORMAT | Print metrics (status, timings) |
-f / --fail-with-body | Non-zero exit on HTTP ≥ 400 |
-L | Follow redirects |
--max-time N | Total timeout (seconds) |
--retry N --retry-all-errors | Retry transient failures |
Keep secrets in env vars — passwords on the command line show up in ps and shell history. Never use -k against production.
Phases: DNS → TCP connect → TLS → TTFB (server work) → total. A high TTFB points at the server, not the network.
Simple loop, then count status codes. Tested: prints 100 200.
xargs -P runs 10 at a time; curl ≥ 7.66 can also parallelise natively with URL globbing.
Drop into ~/.bashrc. Usage: hammer <url> [count=100] [concurrency=10] [extra curl args…]
curl loops are for smoke/regression checks. For accurate RPS and latency histograms use a dedicated tool.
Only load-test systems you own or have permission to test.
Postman: Import → paste a curl command (Code → cURL exports back)
| Code | Meaning | Typical cause |
|---|---|---|
| 200 / 201 / 204 | OK / Created / No Content | Success |
| 400 / 422 | Bad Request / Unprocessable | Validation, bad JSON |
| 401 / 403 | Unauthorized / Forbidden | Missing/expired token / no permission |
| 404 / 405 | Not Found / Method Not Allowed | Wrong path / wrong verb |
| 409 | Conflict | Duplicate / version conflict |
| 429 | Too Many Requests | Rate limit — check Retry-After |
| 500 / 502 / 503 / 504 | Server / Bad Gateway / Unavailable / Timeout | Crash / upstream down / overloaded / slow upstream |