curl advanced (advanced)

Advanced curl: REST API testing, headers, auth, and timing.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

Beyond basic downloads, curl supports all HTTP methods, custom headers, authentication, JSON bodies, and detailed timing breakdowns. The -w format flag extracts timing metrics making curl a powerful HTTP performance testing tool.

Common flags
FlagMeaning
-X --requestHTTP method (GET, POST, PUT, DELETE, PATCH)
-H --headerAdd request header
-d --dataRequest body
-u --userBasic auth user:password
-k --insecureSkip TLS verification
-w --write-outOutput format for response metrics
-s --silentSuppress progress meter
-o --outputWrite response to file
Examples
curl -X POST -H 'Content-Type: application/json' -d '{"key":"value"}' https://api.example.com/v1/resourcePOST JSON to REST API · explain & risk-check →
curl -H 'Authorization: Bearer TOKEN' https://api.example.com/protectedAPI call with Bearer token · explain & risk-check →
curl -w '\nTime: %{time_total}s\nHTTP: %{http_code}\n' -so /dev/null https://api.example.comCheck response time and HTTP status only · explain & risk-check →
curl -I https://example.comHEAD request: show only response headers · explain & risk-check →
curl -u admin:password https://jenkins.example.com/api/json | jq '.jobs[].name'Basic auth + jq parsing · explain & risk-check →
Pro tip

Use `curl -w '%{time_namelookup} %{time_connect} %{time_starttransfer} %{time_total}\n' -so /dev/null URL` to break down DNS, TCP connect, and TTFB — pinpoints exactly where latency occurs.

Related
jq nc openssl advanced
Open the full explainer →More in Networking

Reference text is hand-written and may be incomplete — check man curl for your version. Test destructive commands on a non-production system first.