Curl command cheat sheet

Here is a cheat sheet of some of the most common cURL commands

Curl command cheat sheet

cURL is a versatile tool that can be used for many tasks, including downloading files, uploading files, and making HTTP requests. It is a command-line tool that is available on most operating systems.

Syntax

$ curl [parameters] [URL]

Display the command usage and lists most common options

$ curl --help

Display the command usage and list all available options

$ curl --help all

Basic Operation

COMMANDDESCRIPTION
$ curl http://example.com/Fetch a URL
$ curl -0 http://example.com/file.zipDownload a file
$ curl -L http://example.com/Follow redirections
$ curl https://en.wikipedia.org/wiki/Example.com | jqPretty print JSON

Data Transfer

COMMANDDESCRIPTION
$ curl -d "key1=value1&key2=value2" http:/example.com/post_endpointPost data
$ curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" http://example.com/apiPOST JSON data
$ curl -F "file=@path_to_file" http://example.com/uploadUpload a file

Authentication & Headers

COMMANDDESCRIPTION
$ curl -u username:passwordHTTP Basic authentication
$ curl -H "Authorization: Bearer YOUR_TOKEN" http://example.com/Add Headers

Other Useful Options

COMMANDDESCRIPTION
$ curl --limit-rate 1M -O http://thamdavies.com/file.zipLimit rate (e.g., 1MB/s)
$ curl -C - -O http://thamdavies.com/file.zipResume broken download
$ curl -x http://proxyserver/:port http://example.com/Use a Proxy

Debugging & Info

COMMANDDESCRIPTION
$ curl -v http://example.com/Verbose mode
$ curl -I http://example.comRetrieve only headers
$ curl --versionCurl version & protocols

SSL (Secure Socket Layer)

COMMANDDESCRIPTION
$ curl -k http://example.com/Skip SSL certificate verification
$ curl --cert mycert.pem http://example.comUse SSL Certificate

Common Options

COMMANDDESCRIPTION
-d, --data [data]HTTP POST data
-f, --failFail fast with no output on HTTP errors
-h, --help [category]Get help for commands
-1, --includeInclude protocol response headers in the output
--output [file]Write to file instead of stdout
-O, --remote-nameWrite output to a file named as the remote file
--silentSilent mode
-T, --upload-file [file]Transfer local FILE to destination
[user:password]Server liser and password
-A, --user-agent [name]Send User-Agent name to server

This is just a basic cheat sheet of cURL. There are many other options and features available. For more information, please refer to the cURL documentation.