Insomnia is a handy API client that can be used to quickly set up and send API requests. There are five key areas that are useful to know about when using Insomnia:
- Environment Variables - Up here is where you view and set your variables in order to run requests against our API. More specifically, you’ll need to set email, password, clientId, clientSecret, organisationId and officeId.
- Collection folders and requests - Here you’ll find a list of sample requests:
- Request panel - This is where you can view and edit the requests that you send to First AML’s Public API.
- At the top, you’ll find the request body where you put in what GraphQL fields you wish to receive back in the request response (Tip: You can use
Ctrl + Space
to quickly view what fields are available to use for the current query/mutation). - At the bottom, you’ll find the “Query Variables” section where you put in the actual data used for querying and modifying the data.
- At the top, you’ll find the request body where you put in what GraphQL fields you wish to receive back in the request response (Tip: You can use
- Response panel - This is where you can view the response body of the requests that you send.
- Schema documentation - Provided you’ve used the login request first, you can click on this to view the schema documentation for First AML’s Public API and view all the possible queries and mutations available to you.
How to set up Insomnia
- Head on over to Insomnia’s download page: https://insomnia.rest/download and click download.
- Open the downloaded
Insomnia.Core-XXX.exe
(if on Windows) orInsomnia.Core-XXX.dmg
(if on Mac) and follow the installation instructions. - Open up the Insomnia app.
- Download the following collection file for the First AML Public API: first-aml-public-api-insomnia.json
- Click the ‘Create’ button in the top right and select ‘Import from File’ and select this downloaded file:
6: Click into the First AML Public API Sandbox to open the imported request collection:
How to use variables in Insomnia
Before you can run any requests in Insomnia (except API Status), you’ll need to set up your environment variables.
In Insomnia, variables are displayed as purple tags like so:
To see the list of available environment variables you can press Ctrl + Space when inside of the request body or “Query Variables” sections:
To modify environment variables you can click on the dropdown near the top left of the screen:
Inside of here, you can modify existing variables and add new ones for environment files:
How to run a request
Once you’ve configured your environment variables, you’re ready to send your first request.
First you’ll need to run the ‘Login’ request. You can send a request by clicking the ‘Send’ button near the top of the screen:
Now, given all your credentials have been filled out in the Environment Variables, you should get a response on the right containing an access token. This access token will get carried over to all other existing requests as a tag with type Response → Body Attribute has been setup in the “Bearer” tab of each request like so:
If you create a new request you’ll need to remember to add this in. You can do this by pressing Ctrl + Space while in the ‘TOKEN’ field and searching for/selecting: Response → Body Attribute . You’ll need to fill out the tag like so:
Now you’ve done all this, you should be ready to go!