cURL Cheatsheet
HTTP from the command line.
1 credit
Basics
5 itemsGET
curl https://api.example.com/usersVerbose
curl -v https://... (-vv for more)Follow redirects
curl -L https://...Silent + fail on error
curl -sSfL https://...Output to file
curl -o out.html URL / -O (uses remote name)Methods & body
5 itemsPOST JSON
curl -X POST -H "Content-Type: application/json" -d '{"k":1}' URLPOST from file
curl -X POST --data-binary @body.json URLForm-encoded
curl -X POST -d "a=1&b=2" URLMultipart upload
curl -F "file=@./photo.jpg" -F "desc=cat" URLPUT / PATCH / DELETE
curl -X PATCH -d '{"x":1}' URLHeaders & auth
4 itemsAdd header
-H "Authorization: Bearer $TOKEN"Basic auth
-u user:passCookie
-b cookies.txt -c cookies.txtUser-Agent
-A "MyBot/1.0"Timing & retry
4 itemsTiming breakdown
curl -w "@curl-format.txt" -o /dev/null -s URLRetry
--retry 5 --retry-delay 2 --retry-max-time 30Timeout
--max-time 10 --connect-timeout 5Show headers only
curl -I URL (HEAD)