cheat.sheets:curl
# curl
# Command-line tool for transferring data with URL syntax
# 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
cheat:curl
# To download a file:
curl <url>
# To download and rename a file:
curl <url> -o <outfile>
# To download multiple files:
curl -O <url> -O <url>
# 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 <username>:<password> <url>
# To download a file with a proxy:
curl -x <proxy-host>:<port> <url>
# To download a file over FTP:
curl -u <username>:<password> -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 <partial-file> <url>
# To fetch only the HTTP headers from a response:
curl -I <url>
# 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 <outfile>
# 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
tldr:curl
# curl
# Transfers data from or to a server.
# Supports most protocols, including HTTP, FTP, and POP3.
# More information: <https://curl.se>.
# 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
$
cheat.sh