Basic Syntax
curl [Options] <url>Show Headers
curl -I <url>Follow Redirects
curl -L <url>Save Response to a file
curl -o OUT.html <url> // custom File name
curl -O <url> // uses the remote filenameShow HTTP status code
curl -s -o /dev/null -w "%{http_code}\n" <url>GET with Custom Headers
curl -H "Accept: <Custom Header>" -H "X-Api-Version: 2" <url>Example: curl -H “Accept: application/json” -H “X-Api-Version: 2” https://api.example.com
Get with Bearer token (API auth)
curl -H "Authorization: Bearer <TOKEN>" <url>Basic Authentication (Username:Password)
curl -u username:password <url> NTLM Authentication
curl --ntlm -u <domain>\\<user>:<pass> <url>POST JSON Payload
curl -X POST -H "Content-Type: application/json" -d '{"user":"alice"}' <url>PUT Request
curl -X PUT -d '{"name":"new"}' -H "Content-Type: application/json" <url>DELETE Request
curl -X DELETE <url>Form Submit (application/x-www-form-urlencoded)
curl -X POST -d "<arguments>" <url>Example: curl -X POST -d “q=search” https://example.com/search
URL-encoded fields
curl --data-urlencode "<data>" "<url>"Example: curl –data-urlencode “q=hello world” “https://example.com/search”
Use a Proxy
curl -x <proxy URL> <url>Example: curl -x http://127.0.0.1:8080 https://example.com
Using SOCK5 Proxy
curl --socks5-hostname <sock proxy hostname> <url>Self Signed or Custom Certs (HTTPS)
curl -k <url> // ignore cert validation
curl --cert client.pem --key key.pem <url> // client cert auth
Cookies / sessions
curl -b "session=<session cookie>" <url>Silent Mode
curl -s <url>Display Progress bar
curl --progress-bar -O <file url>HTTP/2
curl --http2 <url>