cURL is a command line tool and library for transferring data with URLs. The command supports a number of different protocols, including HTTP, HTTPS, FTP, SCP, and SFTP. It is also designed to work without user interaction, like in scripts.
Install the package.
A common use case for cURL is to download the resource to a specified file:
$ curl -o file name URL
If the URL contains the file name, you can save the resource directly to a file of that name:
$ curl -O URL
Similarly, you can use
-J to accept a hint from an HTTP server (from the
Content-Disposition header) for what the file should be named. If combined with
-O, curl will use the file name specified by the URL if the HTTP server does not return a file name hint in its response.
Alternatively you can print the resource to stdout by omitting the output options:
$ curl URL
You can use cURL to make HTTP POST requests:
$ curl -d 'request body' URL
If the request body cannot fit on the command line, cURL can read it from a file:
$ curl -d @file name URL
Sometimes, you may need to specify a custom value for the
Content-Type header (cURL's default is
application/x-www-form-urlencoded). You can do this with
-H. For example, if you wanted to make a POST request with a JSON body:
$ curl -d 'json body' -H 'Content-Type: application/json' URL