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

@single9/api-tester

v0.1.10

Published

Api Tester

Downloads

22

Readme

Api Tester

A RESTful API tester

Installation

npm i @single9/api-tester

Usage

const ApiTester = require('@single9/api-tester');

Create APIs

const api = new ApiTester([
  {
    name: '<Api Name>',       // only allow certain words and digits
    path: '<Api Path>',       // e.g. /api/posts
    method: '<HTTP Method>',  // e.g. post
  },
], {
  rootUrl: '<API root URL>'   // e.g. https://jsonplaceholder.typicode.com
                              // Default: http://localhost:3000
  showResult: true,           // set false to disable results console log
  headers: {
    // The headers you want to send. e.g. 'authorization': 'Bearer SAdoweasd...',
  },
  auth: { // authorization
    username: 'username',
    password: 'password',
  }
})

Use Your Api

Usage

ApiTester.<your_api_name>(params)
  • params
    • queryString
    • pathParams
    • body
    • uploads
    • tester

params.queryString

Used for query string. e.g. /users?limit=100

api.test({
  queryString: {
    key: value
  }
})
api.test({
  queryString: [
    {
      name: string,
      value: string | number,
    }
  ]
})

params.pathParams

Used for path parameters. e.g. /user/:id

api.test({
  pathParams: {
    key: value
  }
})
api.test({
  pathParams: [
    {
      name: string,
      value: string | number,
    }
  ]
})

params.body

Used for request body.

api.test({
  body: {
    key: value
  }
})

params.uploads

Used for upload files.

api.test({
  uploads: [
    {
      fieldName: '<form feild name>',
      path: '<file path>'
      filename?: '<file name>',
    }
  ]
})

params.tester

Do some test after responded.

api.test({
  tester: function (res) {
    assert(res === string);
  }
})

Example

const api = new ApiTester([
  {
    name: 'getPosts',
    path: '/api/posts',
    method: 'get',
  },
], {
  showResult: true            // set false to disable results console log
});

api.getPosts()
  .then(result => console.log(result))
  .catch(err => console.error(err))

Upload File

ApiTester.Apis.<ApiName>({
  uploads: [
    fieldName: '<Form Field Name>',
    path: '<File Path>',
    filename: '<File Name>',
  ]
})
const path = require('path');
const api = new ApiTester([
  {
    name: 'uploadFile',
    path: '/api/upload',
    method: 'post',
  },
], {
  showResult: true            // set false to disable results console log
});

const filePath = path.join(__dirname, 'image.jpg'),

api.uploadFile({
    uploads: [
      fieldName: 'file',
      path: filePath,
      filename: path.basename(filePath),
    ]
  })
  .then(result => console.log(result))
  .catch(err => console.error(err))

Example

const assert = require('assert').strict;
const ApiTester = require('@single9/api-tester');

// Create your API schema
const schema = [
  {
    name: 'newPost',  // this is your api function name
    path: '/posts',
    method: 'post',
  },
  {
    name: 'getTodo',
    path: '/todos/:todoId',  // path parameter
    method: 'get',
  },
];

const api = new ApiTester(schema, {
  rootUrl: 'https://jsonplaceholder.typicode.com',
  showResult: true
});

async function start() {
  try {
    await api.newPost({
      // Post Body
      body: {
        title: 'foo!!!!!!',
        body: 'bar!!',
        userId: 1
      },
      // Tester
      tester: function(resp) {
        assert.equal(typeof(resp.id), 'number');
      }
    });

    await api.getTodo({
      pathParams: [{
        name: 'todoId', // replace `:todoId` in path
        value: 2
      }],
      tester: function(resp) {
        assert.equal(typeof(resp.title), 'string');
      }
    });
    
  } catch (err) {
    console.error(err);
  }
}

start();