As a developer, it’s important to have efficient tools for testing and debugging APIs. Alongside well-known tools like Postman or Insomnia, Visual Studio Code offers a useful extension called “REST Client” that provides some interesting advantages.
Integrated Tool
The biggest benefit of the REST Client extension is that it is integrated directly into Visual Studio Code. This means that we can create and test our API requests right within our code editor, without having to switch between different applications. This increases efficiency and productivity, as we have everything in one place.
before you were probably using some tool like Postman or Insomnia. But that mean you should leave your Visual Studio Code instance and open another tool, install it if you do not have it, configure, SO TIME WASTING AND CONSUMING.
Now, we can just install extension REST Client inside our VS Code and then we can define our HTTP request within .http file and test our code without using some other external code.
Syntax Highlighting and Autocomplete
The REST Client extension provides syntax highlighting for creating API requests. This makes the code more readable and organized. Additionally, the extension supports autocomplete, which significantly simplifies the process of writing API requests.
Local Storage of Requests
Another useful feature is the ability to store API requests locally in our work environment. This way, we can easily retrieve and reuse our frequently used requests, without having to rewrite them every time.
Easy API Testing
With the REST Client extension, we can test API requests directly from our code editor. We only need to create a .http file and define our requests within it. Then, we can execute the requests with a single click and view the results right in the editor.
Usage Examples
Let”s go to our Extensions in VS Code and install it or download it from here: https://marketplace.visualstudio.com/items?itemName=humao.rest-client

Now to show you how it works we will create simple Express.js endpoint and test it directly from VS Code.
So we will have one file, index.js and this in memory list and one GET endpoint.

Now we should create some file with .http extension. So we will create course.http file and we will write just two lines of code to test our GET method.

PS: replace the URL with your localhost address.
Now to test this, we can run our application trought the command : node index.js
And while our backend is spinning, we can test our endpoint directly from .http file.
As you can see if we have installed REST client extension, in .http file we can see button Send Request.
If we execute this action, we should get following output in VS Code.

And that’s it, simple, isn’t it. Without leaving our favorite IDE, just to see if everything is working as expected.
We can also add a couple of more request. if we want (for example) to test also some POST request, our .http file can look something like this.

Summary
1- Sending a GET request to an API:
GET https://api.example.com/users
2-Sending a POST request with JSON data:
POST https://api.example.com/users
Content-Type: application/json
{
"name": "John Doe",
"email": "john.doe@example.com"
}
3- Authentication with an API key:
GET https://api.example.com/data
X-API-Key: your_api_key_here
4-Bundling multiple requests in a single file:
# Get user list
GET https://api.example.com/users
###
# Create a new user
POST https://api.example.com/users
Content-Type: application/json
{
"name": "Jane Doe",
"email": "jane.doe@example.com"
}
PS: You can find more details in documentation of this REST Client library,