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

api-virtual-cli

v1.0.0

Published

A CLI to create mock API endpoints

Readme

API CLI - Mock Server

A command-line interface (CLI) tool to create, manage, and serve mock API endpoints quickly and easily. Ideal for frontend developers who need a simulated backend with dynamic responses.

Features

  • Local Server: Spins up a local server to serve your endpoints.
  • Web User Interface: Manage your endpoints through a friendly web UI.
  • Dynamic Routes: Define routes with parameters (e.g., /users/:id).
  • Dynamic Responses: The JSON response body can use variables from the route and the request body.
  • HTTP Method Support: Create endpoints for GET, POST, PUT, PATCH, and DELETE.
  • Integrated CLI & UI: Manage endpoints from the web and get information from the command line.

Installation

To install the tool globally via npm, run:

npm install -g api-virtual-cli

CLI Usage

The tool is operated with the api-cli command.

serve

Starts the API server and the web administration interface.

api-cli serve

By default, the server runs on port 7070. You can specify a different port with the --port or -p option.

api-cli serve --port 8080

Once started, you will see two URLs in your terminal:

  • API Mock Server: The base URL where your endpoints will be available (e.g., http://localhost:7070/api/...).
  • Admin UI: The URL for the web interface to manage endpoints (e.g., http://localhost:7070).

Creating Virtual Endpoints

The primary way to create and manage endpoints is through the web administration interface.

1. The Creation Form

In the UI, you will find a form with the following fields:

  • Endpoint Route: The path for your endpoint, without including /api/. You can add dynamic parameters using the : prefix (e.g., users/:id).
  • HTTP Method: Choose the method for which the endpoint will respond: GET, POST, PUT, PATCH, or DELETE.
  • HTTP Status Code: The status code that the response will return (200, 404, etc.).
  • JSON Response Body: The body of the response in JSON format. This is where you can use dynamic variables.
  • Request Body Schema (Optional): This field appears only for POST, PUT, and PATCH. It allows you to define a schema to use variables from the request body.

2. Dynamic Responses

This is the most powerful feature. You can make your JSON response change according to the request.

Example 1: Using URL Parameters

  • Route: products/:productId
  • Method: GET
  • Response Body:
    {
      "id": ":productId",
      "name": "Sample Product",
      "description": "Details for product :productId"
    }

If you make a GET request to /api/products/123, the response will be:

{
  "id": "123",
  "name": "Sample Product",
  "description": "Details for product 123"
}

Example 2: Using Request Body Parameters

  • Route: users
  • Method: POST
  • Request Body Schema:
    {
      "name": ":name",
      "email": ":email"
    }
  • Response Body:
    {
      "status": "ok",
      "message": "User :name created successfully",
      "data": {
        "name": ":name",
        "email": ":email",
        "id": 12345
      }
    }

If you make a POST request to /api/users with the body {"name": "Ana", "email": "[email protected]"}, the response will be:

{
  "status": "ok",
  "message": "User Ana created successfully",
  "data": {
    "name": "Ana",
    "email": "[email protected]",
    "id": 12345
  }
}

3. Managing Endpoints

Below the form, you will find the "Active Endpoints" table. From here you can:

  • View all the endpoints you have created, with their method and path.
  • Edit an existing endpoint. Clicking it will fill the form with its data for you to modify.
  • Delete an endpoint you no longer need.