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
Data Transfer
COMMAND | DESCRIPTION |
---|
$ curl -d "key1=value1&key2=value2" http:/example.com/post_endpoint | Post data |
$ curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" http://example.com/api | POST JSON data |
$ curl -F "file=@path_to_file" http://example.com/upload | Upload a file |
COMMAND | DESCRIPTION |
---|
$ curl -u username:password | HTTP Basic authentication |
$ curl -H "Authorization: Bearer YOUR_TOKEN" http://example.com/ | Add Headers |
Other Useful Options
Debugging & Info
SSL (Secure Socket Layer)
Common Options
COMMAND | DESCRIPTION |
---|
-d, --data [data] | HTTP POST data |
-f, --fail | Fail fast with no output on HTTP errors |
-h, --help [category] | Get help for commands |
-1, --include | Include protocol response headers in the output |
--output [file] | Write to file instead of stdout |
-O, --remote-name | Write output to a file named as the remote file |
--silent | Silent 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.