DEV Community

Cover image for Insomnia+Resurface: API Usage Logger plugin
Ramón Márquez
Ramón Márquez

Posted on • Originally published at resurface.io

Insomnia+Resurface: API Usage Logger plugin

We have an Insomnia plugin!

It’s no surprise that API design platforms and clients like Insomnia have become part of every developer's toolbox. Being able to create a collection of request templates for specific RESTful endpoints in a matter of seconds, and have them are ready for use with the click of a button is incredibly useful for testing, probing, designing, and even consuming APIs. We added API observability.

We're Insomniacs

Insomnia’s GraphQL support in particular is superb. With integrated schema fetching, auto-complete and linting features, querying GraphQL endpoints has never been easier.

Another great aspect of Insomnia (and the folks at Kong) is their support for Open Source Software, with initiatives such as plugins to extend Insomnia's functionality. With this, and as big fans of OSS ourselves, we decided that it was time Insomnia had yet another feature: A global API system of record.

Design + API Observability

Not a lot of API design tools include observability features, and when they do it is usually part of an enterprise plan (often with a pay-per-request billing model). Currently, Insomnia offers a somewhat hidden feature, which shows past responses for a given request template. However, there is no place where you can quickly explore all the API calls that you've made, regardless of the endpoint. This could be very useful if you're trying to switch environments and compare results between servers. Furthermore, once a request template is deleted, this record is also gone. This can happen when either the individual request or the collection of requests are deleted, or even if any file in the workspace gets corrupted.

Enter Resurface for Insomnia: Your very own API system of record. Resurface logs all the HTTP request-response pairs directly from Insomnia and shows them in a single place where you can explore each one, at any point in time. In addition, Resurface shows hidden errors that you might've missed the first time. Since Resurface works as an append-only database, there is no risk of overwriting or accidentally deleting any individual records. (BTW, OWASP recommends an append-only database for API security.) Resurface runs as a separate containerized solution, so if any Insomnia internal file gets corrupted or accidentally deleted, you will still be able to find all of your records safe and sound in Resurface. This also means that all of it runs locally, on your machine. No data is ever sent to Resurface Labs or anywhere else. The Resurface container is small and it doesn't consume a significant amount of resources.

We are very excited about this, so we've made a little get-started guide over at the Resurface GitHub repo for all the developers, testers, and API designers out there:

GitHub logo resurfaceio / insomnia-plugin

Log API requests and responses made with Insomnia

Resurface Insomnia Plugin

Log API requests and responses made with Insomnia to your own system of record.

Requirements

Set up

  • Go to Insomnia > Preferences > Plugins, type in insomnia-plugin-usage-logger and click Install Plugin.

(Alternatively, check out the manual installation.)

  • Create a new Environment to store the variables used by the logger.

That's it!

Usage

  • Make sure to select the environment you created before (also, make sure the plugin is enabled).
  • Use Insomnia as you would normally.
  • Go to http://localhost:4002 to explore all your logs using the included API Explorer

Happy loggin' 📝

Environment variables

This plugin has access to three environment variables, but only one them is required for the logger to work properly.

All API calls are sent to the database running inside the docker container

The environment variable USAGE_LOGGERS_URL stores this address, which by default should be…

Here's how-to video on installing the Insomnia plugin:

You can also find the plugin on the Insomnia Plugin Hub: API Usage Logger

Happy loggin'

Resurface Lumberjacks

P.S. If you are more on the server-side of things but still a Kong fan, we also got you covered!

See original article here.

Discussion (0)