curl
Command-line tool for transferring data with URLs (https://curl.se)
To make a basic GET request
To save output using the remote filename
To download silently (no progress bar)
To make a POST request with JSON body
curl -X POST <url> \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
To make a POST request with form data
curl -X POST <url> -d "param1=value1¶m2=value2"
To make a PUT request
curl -X PUT <url> -H "Content-Type: application/json" -d '{"key": "value"}'
To add a custom header
curl -H "Authorization: Bearer <token>" <url>
To use basic authentication
curl -u <username>:<password> <url>
To show response headers only
To show both request and response headers (verbose)
To suppress output, show only HTTP status code
curl -s -o /dev/null -w "%{http_code}"
To set a timeout (seconds):
To retry on failure
curl --retry 3 --retry-delay 2 <url>
To use a proxy
curl -x http://<proxy-host>:<port> <url>
To skip SSL certificate verification (insecure)
To specify a custom CA certificate
curl --cacert <ca-cert.pem> <url>
To send a file as multipart form data
curl -F "file=@<path/to/file>" <url>
To pipe output to jq for JSON parsing
To upload a file with PUT
To resume a partial download
To limit download speed (bytes/sec)
curl --limit-rate 100K -O <url>
To make a request with a cookie
curl -b "name=value" <url>
To save and reuse cookies
curl -c cookies.txt -b cookies.txt <url>
To send a request and write headers to a file
curl -D headers.txt <url>
To check the effective URL after redirects
curl -Ls -o /dev/null -w "%{url_effective}"
To use a specific network interface:
curl --interface eth0 <url>
To make a GitHub API request
curl -s -H "Authorization: Bearer <token>" \
"https://api.github.com/repos/<owner>/<repo>/releases/latest" | jq '.tag_name'