As developer, we are using tools to make REST API calls (Postman, Insomnia, PostWoman...), and these tools are very usefull.
The limits
Make calls to test an API is fine, but if you want to edit, version, or simply share it with your team ... it's not very handy.
Indeed, you can use Postman paid plans for instance, but it means that you need to pay, and it means that all your team needs to use Postman, again one more tool...
Do you know REST Client ?
REST Client* is a VS Code extension.
It will let you to send HTTP requests and view responses into VS Code. And only based on a text file, which can easily be versioned among your repository. 🙏
Pros
The main advantage is to be able to version and share your API calls.
If you're working on an internal API, you may want to share how to test a new endpoint with your colleagues.
REST Client is a good easy way to do it !
Another good point is simplicity. All you need to do/have, is ONE file. Also, if you jump between projects and do not remember how works an API/Service on which you did not work since a while, just look at this file !
Cons
You have to use VS Code... but for a lot of known reasons among internets, you are using Emacs, VI, or VS Code 😄
What's next ?
Here is how to begin.
The file
Only create a file with .http extension, for instance doc.http
And then, VS Code will show you the file as :
And by clicking on "Send Request", a new tab with all request response details will be opened.
Go further
You may also use environment variables to easily switch between you env and avoid any api-key or token manually update in the file, or url update etc...
Here is how to use environment variables, just like that :
Here, I created 4 environments : local, dev, staging, production.
These 4 environments have their own host and token variables, with their specific values.
But they also share a variable, named partnerUniqueToken
(don't ask me why ... too many partners don't have several env...).
Hope it helps !
Latest comments (113)
Since Postman free plan will archive your collection (community.postman.com/t/how-do-i-g...), this is great way to share the API with the team!! Nice!!
Great extension!! what about streaming data. Does it support websocket?
Wow, will try this out
Great article, I'm only confused about how to set environments. I can't find any guide to set environments (not even in the extension documentation). Can someone help me please???
Hi @crisdan1905 ,
Don't you find more info event under "Environments and custom/system variables support" section in marketplace.visualstudio.com/items... page ?
Jon
Hi Jon, it's just that I hadn't worked with environment variables before on VSCode, so I had no idea how to create an environment file and VSCode documentation about it was a bit confusing to me. Finally, I figured it out in another guide. It may be useful to explain how to create the file in your documentation :)
Great tool by the way, I just loved it and will keep using it
I still love postman. It have some other features too 😄
yes but you do not have the ability to have it into your repo without, each time, export it, and 20 times in a day... it's painful
Love REST client!
Meh, it's just different. Postman is good and it's simply doing its job. I can't see any reason I should migrate.
Very important to be able to integrate API calls like these into your test pipelines -- so does it work-with/replace Newman?
And for those using vim, you can use something like this :
github.com/diepm/vim-rest-console :)
Thanks a lot @hyde_stevenson :)
You're welcome :)
We could easily use it if this add-on would be compatible with restclient.el (an Emacs package with a similar purpose), as both editors are widely used at our company. But in this way, it’s just another way to do the same thing…
We do not want create a standard... just show an easy way to share infos between colleagues ;)
Yeah, but this is vs code dependent. Deal breaker.
Meh, Postman is still better than this in my humble opinion. They're making you pay for a good reason. I'm getting old, I want a nice an intuitive interface. I pay to save my time and Postman is really helping with this.
EDIT: I just tested it, still a big MEH. Not sure how big your projects are but I feel this is not suitable for the size of my projects.
We have a lot of REST APIs to test, as well as a lot of variables that need changing on the fly quickly by testers to test certain scenarios. For us, Postman works better. This plugin is ok but we have powershell scripts that can do the same stuff and its not as intuitive.
I get the idea behind this in that it just "fits" into version control etc and in theory its easier to have VSCode installed, but I think there is space for both of these tools. This extension fits nicely for quick dev test stuff, but I think I still prefer Postman for more complex scenarios, plus it has a host of other features.
Hmm, if it fit you and your team organisation, it can be a solution, for sure :) We're trying here, to avoid to get thousands of tools and be sure to be up to date with "just the repo".
You must be doing a lot. I use a lot of tools too (I work fully digitally), but I close the ones I don't use right away.
Some ones are always opened you know (IDE, Slack, Database connection, Terminal, Trello, Chrome etc..) hard to be able to close each tool one you're done with.
That's really not a lot. And that's about all I need as a fullstack developer. The terminal is part of VSCode and I use pen and paper for my tasks (with ClickUp for project management). I don't use any messaging app WHILE coding, no distractions.
Even tho I dabble with many parts of the systems I maintain and build, I don't have more than 6-8 apps open at the same time. And this is not even half of the apps I can handle open at the same time.
I feel like we're bringing a problem that does not exist just to justify the use of this tool... and I feel like a hater, so I'll stop at this. ;) I hope it's useful to anyone else. I'll try to get more invested into testing it out in the future.
Woah, that's super cool. Have found in the past that saved Postman collections are kinda awkward to deal with in a team environment, but with this one could create a saved collection of requests, and then commit that to source control to share. If any of the requests change you just update that file.
Seems to me too it wouldn't be super hard to generate a Postman collection from a file that REST Client uses, so for those teammates that don't use VS Code for whatever reason, you could still have them generate an equivalent collection to use in Postman.
We have been using this extension in our project for the last 1year and a half and it works really well 👍🏽
It's also a very light way to document your endpoints.
Thanks for sharing 💯