TL;DR

curl is the first tool for API debugging. Essentials: curl -sS URL, curl -X POST -H 'Content-Type: application/json' -d '{}' URL, curl -w '%{http_code}'.

Basic Requests

NeedCommand
GET with headers in outputcurl -i URL
Silent modecurl -sS URL
Headers onlycurl -I URL
Follow redirectscurl -L URL
Save to filecurl -o file.txt URL / -O

Sending Data

NeedCommand
POST JSONcurl -X POST -H 'Content-Type: application/json' -d '{"k":"v"}' URL
Form datacurl -d 'k=v&k2=v2' URL
Upload filecurl -F 'file=@./a.txt' URL
Custom headercurl -H 'Authorization: Bearer TOKEN' URL
Cookiescurl -b 'name=value' URL

Useful Flags

FlagPurpose
-w '%{http_code}\n'Print status code only
--max-time 10Timeout (seconds)
--connect-timeout 5Connect timeout
-kSkip TLS verification (debug only)
-x http://host:portUse proxy
-A 'UA'Custom User-Agent

Debugging Notes

Sources

最后更新:2026-08-02