HTTP API
Theory: CURL
One browser isn't enough for testing HTTP APIs. Browsers can be used only in simple situations when you don't need to expose the headers and make requests other than GET. In all other cases, you need more powerful and more specialized tools.
Curl is a command line utility created back in 1998. It is actively used for downloading files and in automation scripts. In the API documentation of many services, there are examples of how to execute a request using curl, along with the description of the service itself.
It's included in some operating systems by default. If you don't have it, install it using this command:
Make sure everything works:
The easiest way to use curl is to make a GET request to a website:
In this case, curl will print the body of the response, which is the HTML of the site in our case. You can save it to a file by redirecting it:
If we want to see the response headers, the query becomes:
In this case, curl sends a HEAD request, which the server should respond to by returning the headers without the body.
According to the specification, the headers returned when a made HEAD request must be the same as for a GET request, but the actual response is not.
Therefore, it's better to perform a GET request for accuracy:
If you want to see the answer and also the query, then the --verbose flag is what you need. It will show everything, including the body of the answer:
Entering headings:
And the bodies in the query:


