Making GET Requests with Curl
Curl
, short for Client for URLs, is a command line tool that allows us to transfer data to and from a server. It is free and open-sourced. It supports multiple protocols, including HTTP. Find out more at curl documentation or their source code
Why use Curl?
Curl
provides an easy way to make requests to a server from the command line or from inside a script. It is especially helpful for testing APIs while building applications because making a request with curl allows you to hit endpoints for which the corresponding user interfaces do not yet exist.
We can easily use curl on any CLI.
curl http://www.google.com
Or we can install extensions for better visualization:
Steps:
1. Install REST Client
2. Create/Open a new File
3. Ctrl+Shift+P and Change Language Mode to HTTP
4. Type in curl commands and start requesting!
curl --request GET www.google.com
5. Other Alternatives
- Thunder Client Someone wrote a nice article here
- Postman
- Insomnia
Top comments (1)
Thanks for the article. A brief follow up:
You can save the newly created files with the extension
.http
(I believe this is suggested), then you can configure your OS to associate*.http
files with Visual Studio Code and then you have nifty littlecurl
snippets at your disposal from your file system