curl Command Reference - CodeSwordsman

Common parameter combos for HTTP requests, auth, debugging and resumable downloads in curl.

curl 7.68+Updated 2026-10-2927 commands

Requests & Output

Send a GET request and print the response body

curl https://api.example.com/users

Silent mode that still prints errors, suitable for scripts

curl -sS https://api.example.com/health

Print response headers together with the body

curl -i https://api.example.com/users

Fetch headers only to check availability quickly

curl -I https://example.com

Print only the status code for script checks

curl -s -o /dev/null -w "%{http_code}\n" https://example.com

Methods & Bodies

Send a POST request with a JSON body

curl -X POST https://api.example.com/users -H "Content-Type: application/json" -d '{"name":"Tom"}'

Read the body from a file and replace the resource

curl -X PUT https://api.example.com/users/42 -H "Content-Type: application/json" -d @payload.json

Partially update resource fields

curl -X PATCH https://api.example.com/users/42 -d '{"active":false}'
Risky

Delete the specified resource

curl -X DELETE https://api.example.com/users/42

Send GET query params encoded automatically

curl -G --data-urlencode "q=Vue 3" --data-urlencode "page=2" https://api.example.com/search

Upload a file as multipart form data

curl -F "file=@./avatar.png" -F "name=Tom" https://api.example.com/upload

Auth & Cookies

Access an endpoint with Basic authentication

curl -u admin:secret https://api.example.com/basic

Access a protected endpoint with a Bearer token

curl -H "Authorization: Bearer <TOKEN>" https://api.example.com/me

Pass an API key through a custom header

curl -H "X-API-Key: <API_KEY>" https://api.example.com/data

Log in and save response cookies to a file

curl -c cookies.txt -d "user=tom&pass=123" https://example.com/login

Reuse saved cookies to keep the session

curl -b cookies.txt https://example.com/profile

Debugging & Network

Print the full request and response for troubleshooting

curl -v https://api.example.com/users

Bypass DNS and point the domain at a local host

curl --resolve api.example.com:443:127.0.0.1 https://api.example.com/health

Send the request through a proxy

curl -x http://127.0.0.1:7890 https://example.com

Limit connect and total time so requests never hang

curl --connect-timeout 2 --max-time 5 https://example.com

Print the status code and total request time

curl -s -o /dev/null -w "状态:%{http_code} 耗时:%{time_total}s\n" https://example.com

Skip certificate verification for self-signed testing only

curl -k https://self-signed.example.com

Disabling verification removes MITM protection; never use in production

Download & Resume

Follow redirects and save with the remote file name

curl -L -O https://example.com/files/app.tar.gz

Save with a custom name when the URL has query params

curl -L -o app.tar.gz "https://example.com/download?id=42"

Resume an interrupted download from where it stopped

curl -C - -O https://example.com/files/big.iso

Limit download speed to avoid saturating bandwidth

curl --limit-rate 500k -O https://example.com/files/big.iso
Risky

Run a remote script directly; risky if the source is untrusted

curl -sL https://example.com/install.sh | bash

Download and review the script before executing it

Related tools

This website uses cookies to ensure you get the best experience on our website. Privacy Policy.