Post/Code

HomeAboutUsesNow

Insomnia, cURL and JSON Path.

I have been a fan and user of the Insomnia REST Client for quite some time. Initially, I was a regular Postman user, but when Postman switched from being a Chrome browser extension to a standalone app, their proxy user authentication and support was not great. (If I understand correctly, Postman used to piggyback on Chrome's proxy auth - which worked great!) As a result, and after much GitHub issue browsing, I just could not (and still cannot) get Postman to work through the corporate proxy at work.

As is often the case though, one door closing leads to another door opening and I am so glad it did.

Insomnia is great!

I love the UI, I love the name (Finally, a REST client you'll love) and I love that Insomnia has actually taught me a few things I did not know, such as:

cURL

I'll admit, cURL was a little obscure to me (still is). However, ever since discovering that Insomnia allows you to quickly and easily recreate API calls by pasting the cURL into the address bar, I have become a regular user. (Special tip: When viewing the Resquest pane in your dev tools, right click on the request you are interested in and then select Copy as cURL. Then paste it into the Insomnia address bar.)

The above, combined with my increased usage of Node.js, which has me spending more time in the terminal than ever before, and I have started to use cURL to test basic GET commands instead of Insomnia!

Note: This is only for basic GET commands, for more complex calls, I still find Insomnia far quicker and easier to setup a call.

JSON Path

Currently, I am working on a project which has some APIs which return quite a lot of data. When interrogating the data for possible bugs and root causes, I work in Insomnia or transfer browser calls to Insomnia for the following reasons:

  1. Seeing both request and response in one pane far surpasses having to switch between panes in the browser dev tools.
  2. Being able to quickly change values and re-submit API requests far surpasses having to redo actions in the browser. (Or type out cURL commands)
  3. (Again) The UI far surpasses what appears in the browser. (I love dark modes)
  4. Being able to screenshot or share cURLs is far easier in Insomnia than it is from the browser. (But only by a little...)

Now, there is a 5th point to that list:

JSON Path

While, somewhat frustratedly, scrolling up and down through the response pane and minimising/maximising objects and arrays to get a better sense of the large data sets I was receiving, I noticed the small input bar at the very bottom right of the screen. When clicking the little ? icon at the end the line, I discovered this:

Use JSON Path to filter the response body. Here are some examples you might use on a book store API.

  • $.store.books[*].title
  • $.store.books[?(@.price < 10)].title
  • $.store.books[-1:]
  • $.store.books.length

This was just what I was looking for!

Using JSON Path makes it so much easier to get a sense of the overall shape and quality of the data you are getting back than scanning it manually. You can very efficiently narrow down the data to particular areas of focus, with an almost JSON like query language.

It strikes me, that, often times, the best software or technology, not only finds a useful place in your workflow, but also teaches or reveals things to you that you were not aware of before. I exceptional cases, the software teaches you things that are really, incredibly useful!

Feature request: Smart auto-complete for JSON Path queries based on the data you have received.