To make a GET request using cURL, call curl followed by the target URL. cURL automatically selects the HTTP GET request method unless you use the -X, --request, or -d command line option with the cURL request. In this cURL GET example, we send requests to the ReqBin echo URL. The target URL is passed as the first command-line option. No additional cURL parameters are passed since in this cURL GET example we don't want to send additional HTTP headers to the server.
cURL stands for Client for URLs, it is a popular command-line tool for Linux, Windows, and macOS for transferring data over the network using HTTP, HTTPS, FTP, and SFTP protocols. You can make GET, POST, and HEAD requests to the server, retrieve HTTP headers from the server, download HTML pages, upload files, submit forms, and more.
Basic cURL GET example
cURL is very easy to use, this basic cURL GET example demonstrates how easy it is to make a GET request to the target server using cURL.
cURL GET example
How to send HTTP headers with a cURL GET request?
To make a GET request with HTTP headers, use the -H command-line option. You can pass as many HTTP headers with your cURL GET request as you like using the -H command line multiple times.
In this cURL request example, the Accept: application/json header is important because, without this header, the server might return data in a different format.
An example of downloading the page HTML from the ReqBin echo URL.
cURL Get HTML Page Request Example
In this simple cURL GET request example, we did not pass any additional headers, and cURL automatically adds an Accept: */* request header that tells the server that the cURL client can accept data in any format.
Server response to our cURL get HTML Page request.
Server Response to cURL Request
HTTP/1.1 200 OK
html code here