TWU - Insomnia

TWU - Insomnia
Aaron Kronberger profile picture

By Aaron Kronberger, Consultant

Categories: Tools

Have you ever noticed when browsing the web that occasionally there will be a piece of information on a website that updates without refreshing the whole page? It might load a short while after the other parts of the page load or even when a particular event occurs—such as getting to the end of a list or registering your username on a site. For example, say you’re looking at a web page that shows what temperature it is outside and every so often, without your interaction, the temperature updates to reflect the present conditions. You may be thinking: “It’s magic! I didn’t even touch my phone!” While that would certainly be more entertaining than reality, there’s a simpler explanation. Indeed, it’s likely that this data is being retrieved asynchronously or “on-demand” from a server that has up-to-date temperature data. This blog post will share some details on a tool that is used at High Monkey called Insomnia ( that is used to assist in the development of programmatic interactions with data on servers. 

For a little more technical background, a significant portion of the modern web utilizes what is known as “AJAX” or Asynchronous JavaScript and XML. This is simply an asynchronous (“on-demand” or “when available”) request to retrieve data made from a front end like your web browser to a server on the back end.
Without getting too far into the weeds, many servers that are used as endpoints for interacting with data run what is known as a “RESTful API” which simply sets a few standards for interacting with the data on the server:
  1. You must state what action you are taking with the data (Create, read, update or delete)
  2. The data should be interactable via an easy to understand URL structure, like "/users" to perform some operation on user "resources" or objects
  3. The interaction is stateless such that each request contains all the information needed for the server to fulfill the request
The value of the Insomnia tool is that it provides a Graphical User Interface for rapidly constructing, sending, receiving and debugging these requests. All common tasks in a developer’s day to day operations, and while the work done in the program may not always make its way into the final product, it can definitely save time and effort in achieving a high-quality end result.

Insomnia’s interface looks like this:

insomnia interface 1

The left pane displays saved requests, the upper right pane shows the various parameters that make up the request, and the bottom right pane displays the response to the request after it is sent.

For a real-world example, imagine you are at work using an internal website which--as a small feature on an administrative page--provides a listing of users registered on your website, 6 people at a time. What happens when you want to view the next 6 people in the list? You would commonly click a “Next” arrow to view the next set of users in the list. As a development best practice, when the “Next” arrow is clicked, should the server send the entire webpage again, with just the little bit of relevant information changed? Probably not. Now imagine you are but one joyful administrator in a sea of administrators all trying to view this webpage at the same time.  Now we most certainly don’t want to do this. We want to request data as efficiently as possible and only update what needs to be changed.

Here’s an example of what a request might look like against a real API running at :

insomnia interface 2

In this example request, (1) shows which action we’re requesting: GET (which is essentially a “Read” operation), (2) what resource we’re requesting: some Users, and (3) a response code and the actual data response from the server running the API, as well as the time it took and the size of the returned data. 
Here’s a request specifically getting paged data like what was described in the previous scenario: 

insomnia interface 3 
This is the type of data that would then be processed and displayed to update elements on the page dynamically, such as the list of users in the previous example.

In addition to enabling rapid prototyping of requests, Insomnia has other great features like grouping requests into “Workspaces”, which for High Monkey correspond to different client projects. The tool also makes it easy to add authentication information to requests which is a very common requirement. 
A final useful feature of Insomnia to mention is that Insomnia will generate code based on the request parameters, in a number of languages including JavaScript and C#--two of the predominant languages that High Monkey uses. 
insomnia interface 4
These are just some of the basic uses—the tool offers much more. It’s small, quick to open and best of all: Free! Insomnia is available for Mac, Windows, and Linux for free at