npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aqovia/insomnia-api-helper

v0.0.1

Published

A library for using an Insomnia API design document's requests within JavaScript

Readme

Insomnia API Helper

A library for using an Insomnia API design document's requests within JavaScript, e.g. for testing

Using The Library

Create An API Instance

  1. Export your Insomnia API design document as an Insomnia v4 JSON file
  2. Import/parse the JSON file into your project as an object
  3. Construct an instance of the API using:
const myApi = new InsomniaApi(jsonApiObject, optionalNameOfEnvironmentToUse);

An instance will be created with all environment variables instantiated as per your selected environment.

Environment Variables

When making requests, environment variable placeholders in the request will automatically be populated, as per your selected environment. Environment variables can be accessed (and changed) via the myApi.envVars object.

You can also call myApi.setEnvironment(environmentName) to refresh all environment variables as per the specified environment.

Auth

If required, set an OAuth2 token on the API, which will be used in all requests:

myApi.setAuthToken(myAuthToken);

Requests

Create an instance of a request that is defined in your design document by its name, and modify it as required:

const updateRequest = myApi.getRequestByName("Update User By ID");

Set Path Parameters

updateRequest.pathParameters["id"] = "101";

Set Query Parameters

updateRequest.queryParameters["someQueryParameter"] = "value";

Set Body

updateRequest.body = {
  firstName: "John",
  lastName: "Smith",
  email: "[email protected]"
};

Send Request

const response = await updateRequest.send();

Note. This makes and returns a fetch request/response.

Example Usage

import { InsomniaApi } from "@aqovia/insomnia-api-helper";
import usersApiDesignDocument from "./users-api.json" assert { type: "json" }; // an exported Insomnia v4 JSON design document
import { expect } from "chai";

describe("Users API", function () {
  const environment = process.env.SELECTED_ENVIRONMENT || "Test";
  const usersApi = new InsomniaApi(usersApiDesignDocument, environment);

  before(async function () {
    const authToken = await getAuthToken( // your own custom logic to retrieve an auth token
      usersApi.envVars["tokenUrl"],
      usersApi.envVars["clientId"],
      usersApi.envVars["clientSecret"]
    );

    usersApi.setAuthToken(authToken);
  });

  let newUser;

  it("should create a user", async function () {
    newUser = {
      email: "[email protected]",
      firstName: "John",
      lastName: "Smith",
      phone: "12345",
    };

    const createUserRequest = usersApi.getRequestByName("Create A User");
    createUserRequest.body = { ...createUserRequest.body, ...newUser };
    
    const createUserResponse = await createUserRequest.send();
    expect(createUserResponse.status).to.equal(201);

    const createUserResponseBody = await createUserResponse.json();
    expect(createUserResponseBody).to.have.property("id");
    
    newUser.id = createUserResponseBody.id;
  });

  it("should retrieve a user by ID", async function () {
    const getUserRequest = usersApi.getRequestByName("Get User By ID");
    getUserRequest.pathParameters.id = newUser.id;
    
    const getUserResponse = await getUserRequest.send();
    expect(getUserResponse.status).to.equal(200);

    const getUserResponseBody = await getUserResponse.json();
    expect(getUserResponseBody.email).to.equal(newUser.email);
  });
});