- #INSOMNIA API TUTORIAL HOW TO#
- #INSOMNIA API TUTORIAL INSTALL#
- #INSOMNIA API TUTORIAL PASSWORD#
- #INSOMNIA API TUTORIAL PLUS#
Now that we have our folder made, we can make our first request.
![insomnia api tutorial insomnia api tutorial](https://tutorials.ducatindia.com/wp-content/themes/asb-ducat-tutorials/images/nodejs/restful-api-in-nodejs9.png)
This project was called Trip Split, so that's what I'll title my folder. You can find the docs here if you're interested. Request bodies should be in JSON format, and other than register & login, the routes require an Authorization header with a JWT (JSON Web Token) as the value.
![insomnia api tutorial insomnia api tutorial](https://2tjosk2rxzc21medji3nfn1g-wpengine.netdna-ssl.com/wp-content/uploads/2021/04/insomnia-key-auth-test-no-768x82.png)
I'm going to use an API that I built to demonstrate making HTTP requests that cover all CRUD functionality. the organization is completely up to you. Or, if it's a large project, you may want to use the entire workspace and have various folders within it. Let's make a folder, specific to our project.
#INSOMNIA API TUTORIAL PLUS#
To begin making requests click the plus icon, which will trigger a dropdown giving you the option to either make a New Request or create a New Folder. Once the app is open, you'll see a mostly "blank" workspace. Step 3: Make your 1st HTTP GET Request w/ Insomnia Once you're more familiar with the functionality of your API, go ahead and open up Insomnia. What's the base URL? Are there any params or headers required? Do you need a request body and, if so, is it in JSON format? Etcetera, etcetera. Read through them and figure out what you'll need to make each request. Hopefully your API has a nice set of docs to guide you through this process. There are directions to prompt you once you're there.
#INSOMNIA API TUTORIAL INSTALL#
Head over to the official Insomnia website to install it on your machine. Feel free to try different platforms to see which one you like best. However, there are more options out there (a popular choice being Postman).
#INSOMNIA API TUTORIAL HOW TO#
In this article I'll be using Insomnia to demonstrate how to do this. Testing endpoints will save time, prevent potential errors (and lots of stress!), and give you a better relationship/understanding with your API. But without the ability to test your endpoints, you're bound to run into some issues. Insomnia has become an integral tool in my workflow when doing exploratory testing on APIs.So you're building an app that makes various HTTP requests, eh? You know how to make the API calls, whether you're using a library or good ole. With Insomnia, you can set up a request that hits a generateToken endpoint, then use its response with other endpoints. Let’s say you have an endpoint that provides a token that allows you to access other endpoints. My favorite feature of Insomnia is the ability to chain requests.
#INSOMNIA API TUTORIAL PASSWORD#
In each environment I had base_url, username, and password variables, allowing me to quickly switch between and test each environment. ease the friction of switching between each of those URLs, I created an Insomnia environment for each backend. On top of that, each endpoint required standard HTTP authentication credentials, e.g. On a recent project, our client had different backends for development, test, and production - each with its own URL.
![insomnia api tutorial insomnia api tutorial](https://i.ytimg.com/vi/fzLPHpOP3Wc/maxresdefault.jpg)
The usefulness of this feature is amplified when combined with the ability to swap between different sets of environmental variables. For example, you can set a base_url variable and use that across multiple requests to hit different REST endpoints on that URL.
![insomnia api tutorial insomnia api tutorial](https://2tjosk2rxzc21medji3nfn1g-wpengine.netdna-ssl.com/wp-content/uploads/2021/04/insomnia-key-auth-test-no.png)
Insomnia allows you to set environment variables that can be reused across multiple requests. Instead of having them meticulously copy over each request, you can export a JSON document and share it with them! Swappable Environments This becomes useful when you have team members who want to utilize an Insomnia workspace that you’ve built up over the course of the project. One great feature of Insomnia is the ability to export and share workspaces. I keep using it thanks to three features that allow my team to be more productive when messing around with new APIs. I was initially drawn in by its clean UI and ease of use. A while ago, I started using the Insomnia REST Client for exploratory API testing.