curl
Created: January 06, 2025
1. Send JSON
curl -X POST [URL] \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
2. Simulate a Web Form
Use -d for URL-encoded form data or -F for multipart form data (file uploads).
curl [URL] -d "key1=value1&key2=value2"
curl [URL] -F key1=value1 -F key2=value2 -F file=@filename
3. Download a File
Use -O to save with the remote filename, or -o to specify a custom name.
curl -O [URL]
curl -o output.txt [URL]
4. Send Cookies
curl --cookie "name=value" [URL]
To save and reuse cookies across requests:
curl -c cookies.txt [URL] # Save cookies to file
curl -b cookies.txt [URL] # Send cookies from file
5. Ignore SSL Certificate Errors
curl -k [URL]
6. Get Only HTTP Headers
curl -I [URL]
7. Download Multiple Files
curl -O [URL1] -O [URL2]
8. HTTP Authentication
curl -u username:password [URL]
For bearer tokens:
curl -H "Authorization: Bearer [TOKEN]" [URL]
9. Follow Redirects
curl -L [URL]
10. Connect via Proxy
curl -x [protocol://][host][:port] -U user:password [URL]
11. Verbose Output
curl -v [URL]
12. Set Custom Headers
curl -H "X-Custom-Header: value" [URL]
13. Timeout
curl --connect-timeout 5 --max-time 10 [URL]
14. Resume a Download
curl -C - -O [URL]
15. Show Response Headers with Body
curl -i [URL]
16. Silent Mode
Suppress progress meter and error messages:
curl -s [URL]
curl -sS [URL] # Silent but show errors
17. Write Output to File
curl [URL] -o filename.txt
curl [URL] > filename.txt
18. Rate Limiting
curl --limit-rate 100K [URL]
19. Send Data from File
curl -X POST [URL] -d @data.json -H "Content-Type: application/json"
20. PUT and DELETE Requests
curl -X PUT [URL] -d '{"key": "value"}' -H "Content-Type: application/json"
curl -X DELETE [URL]