Appearance
Curl Cheatsheet
Make a POST Request
-X POST
shell
curl -X POST https://catonmat.net
curl -X POST https://catonmat.net
Add POST Data to a Request
-d var=val
shell
curl -d 'login=emma&password=123' -X POST https://google.com/login
curl -d 'login=emma' -d 'password=123' https://google.com/login
curl -d '{"login": "emma", "pass": "123"}' -H 'Content-Type: application/json' https://google.com/login
curl -d '<user><login>ann</login><password>123</password></user>' -H 'Content-Type: text/xml' https://google.com/login
curl -d 'hello world' -H 'Content-Type: text/plain' https://google.com/login
curl -d '@data.txt' https://google.com/login # Send a POST Request with Data from a File
curl --data-urlencode 'name=john depp' https://google.com/login # URL-encode POST Data
curl -d 'login=emma&password=123' -X POST https://google.com/login
curl -d 'login=emma' -d 'password=123' https://google.com/login
curl -d '{"login": "emma", "pass": "123"}' -H 'Content-Type: application/json' https://google.com/login
curl -d '<user><login>ann</login><password>123</password></user>' -H 'Content-Type: text/xml' https://google.com/login
curl -d 'hello world' -H 'Content-Type: text/plain' https://google.com/login
curl -d '@data.txt' https://google.com/login # Send a POST Request with Data from a File
curl --data-urlencode 'name=john depp' https://google.com/login # URL-encode POST Data
POST a file
-F
shell
curl -F '[email protected]' https://google.com/profile
curl -F '[email protected];type=image/png' https://google.com/profile
curl -F '[email protected];filename=me.png' https://google.com/profile
curl -F '[email protected]' https://google.com/profile
curl -F '[email protected]' https://google.com/profile
curl -F '[email protected];type=image/png' https://google.com/profile
curl -F '[email protected];filename=me.png' https://google.com/profile
curl -F '[email protected]' https://google.com/profile
Add HTTP Headers
-H 'Header: Value'
shell
curl -H 'Accept-Language: en-US' https://google.com
curl -H 'Accept-Language: en-US' -H 'Secret-Message: xyzzy' https://google.com
curl -H 'Puppies;' https://google.com
curl -H 'Accept-Language: en-US' https://google.com
curl -H 'Accept-Language: en-US' -H 'Secret-Message: xyzzy' https://google.com
curl -H 'Puppies;' https://google.com
Change the User Agent
-A 'User Agent'
shell
curl -A 'Googlebot/2.1 (+http://www.google.com/bot.html)' https://washingtonpost.com
curl -H 'User-Agent: Googlebot/2.1 (+http://www.google.com/bot.html)' https://google.com
curl -A 'Googlebot/2.1 (+http://www.google.com/bot.html)' https://washingtonpost.com
curl -H 'User-Agent: Googlebot/2.1 (+http://www.google.com/bot.html)' https://google.com
Set Cookies
-b name=value
shell
curl -b 'session=abcdef' https://google.com
curl -b 'session=abcdef' -b 'loggedin=true' https://google.com
curl -b 'session=' https://google.com
curl -b cookies.txt https://www.google.com # Load Cookies from a File
curl -c cookies.txt https://www.google.com # Save Cookies to a File
curl -b 'session=abcdef' https://google.com
curl -b 'session=abcdef' -b 'loggedin=true' https://google.com
curl -b 'session=' https://google.com
curl -b cookies.txt https://www.google.com # Load Cookies from a File
curl -c cookies.txt https://www.google.com # Save Cookies to a File
Save the Response to a File
-o file
shell
curl -o response.txt https://google.com?q=kitties
curl -O https://catonmat.net/ftp/digg.pm
curl -o response.txt https://google.com?q=kitties
curl -O https://catonmat.net/ftp/digg.pm