CURL
Cheat Sheet
Process a single GET request, and show its output on stdout
curl http://path.to.the/file
Download a file and specify a new filename
curl http://example.com/file.zip -o new_file.zip
Download multiple files
curl -O URLOfFirstFile -O URLOfSecondFile
Download all sequentially-numbered files (1-24)
curl http://example.com/pic[1-24].jpg
Download a file and follow redirects
curl -L http://example.com/file
Download a file and pass HTTP Authentication
curl -u username:password URL
Download a file with a Proxy
curl -x proxysever.server.com:PORT http://addressiwantto.access
Download a file from FTP
curl -u username:password -O ftp://example.com/pub/file.zip
Get an FTP directory listing
curl ftp://username:password@example.com
Resume a previously failed download
curl -C - -o partial_file.zip http://example.com/file.zip
Fetch only the HTTP headers from a response
curl -I http://example.com
Fetch your external IP and network info as JSON
curl http://ifconfig.me/all/json
Limit the rate of a download
curl --limit-rate 1000B -O http://path.to.the/file
POST to a form
curl -F "name=user" -F "password=test" http://example.com
POST JSON Data
curl -H "Content-Type: application/json" -X POST -d '{"user":"bob","pass":"123"}' http://example.com
POST data from the standard in / share data on sprunge.us
curl -F 'sprunge=<-' sprunge.us
Transfers data from or to a server
curl
Download the contents of a URL to a file
curl http://example.com --output path/to/file
Download a file, saving the output under the filename indicated by the URL
curl --remote-name http://example.com/filename
Download a file, following location redirects, and automatically continuing (resuming) a previous file transfer and return an error on server error
curl --fail --remote-name --location --continue-at - http://example.com/filename
Send form-encoded data (POST request of type application/x-www-form-urlencoded). Use --data @file_name or --data @‘-’ to read from STDIN
curl --data 'name=bob' http://example.com/form
Send a request with an extra header, using a custom HTTP method
curl --header 'X-My-Header: 123' --request PUT http://example.com
Send data in JSON format, specifying the appropriate content-type header
curl --data '{"name":"bob"}' --header 'Content-Type: application/json' http://example.com/users/1234
Pass a username and password for server authentication
curl --user myusername:mypassword http://example.com
Pass client certificate and key for a resource, skipping certificate validation
curl --cert client.pem --key key.pem --insecure https://example.com
To download a file
curl
To download and rename a file
curl -o
To download multiple files
curl -O -O
To download all sequentially numbered files (1-24)
curl http://example.com/pic[1-24].jpg
To download a file and pass HTTP authentication
curl -u :
To download a file with a proxy
curl -x :
To download a file over FTP
curl -u : -O ftp://example.com/pub/file.zip
To get an FTP directory listing
curl ftp://username:password@example.com
To resume a previously failed download
curl -C - -o
To fetch only the HTTP headers from a response
curl -I
To fetch your external IP and network info as JSON
curl http://ifconfig.me/all.json
To limit the rate of a download
curl --limit-rate 1000B -O
To get your global IP
curl httpbin.org/ip
To get only the HTTP status code
curl -o /dev/null -w '%{http_code}\n' -s -I URL
Last updated