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

v2.0.0

Published

A CLI tool to create, manage, and serve mock API endpoints. Supports delay simulation, faker data, request logs, OpenAPI export, and a premium dark-mode admin UI.

Readme

API CLI — Mock Server v2.0

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 Express server to serve your mock endpoints.
  • Premium Admin UI: Dark/light mode dashboard with sidebar navigation to manage everything visually.
  • Dynamic Routes: Define routes with URL 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.
  • Delay Simulation: Configure a delay (in ms) per endpoint to simulate real network latency.
  • Faker Hints: Use {{faker.x.y}} placeholders in your response body to generate realistic fake data automatically.
  • Custom Response Headers: Define custom HTTP headers per endpoint (e.g., Authorization, X-Custom-Header).
  • Request Logger: Live feed of all incoming requests with method, path, status code, and response time. Visible in the UI and via CLI.
  • OpenAPI Export: Automatically generate a basic OpenAPI 3.0 spec from all your active endpoints.
  • Import & Export: Save and restore your endpoints as .rmm files.
  • Integrated CLI: Manage endpoints and view logs directly from your terminal.

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 the following URLs in your terminal:

| URL | Description | |---|---| | http://localhost:7070/api/... | Base URL for all your mock endpoints | | http://localhost:7070 | Admin UI dashboard | | http://localhost:7070/admin/export/openapi | Generated OpenAPI 3.0 spec | | http://localhost:7070/admin/logs | Request logs (JSON) |


list

Displays a formatted table of all active mock endpoints.

api-cli list
api-cli list --port 8080

Output columns: Method · Path · Status Code · Delay · Random


logs

Shows the latest incoming requests received by the mock server.

api-cli logs
api-cli logs --limit 50
api-cli logs -n 10 --port 8080

Options:

  • -n, --limit <n> — Number of log entries to display (default: 20)
  • -p, --port <port> — Port the server is running on (default: 7070)

reset

Deletes all active mock endpoints from the running server.

api-cli reset
api-cli reset --port 8080

⚠️ This action is permanent. Use Export first if you want to keep your endpoints.


Admin UI

Open http://localhost:7070 in your browser to access the dashboard. It has three sections:

🔌 Endpoints

The main section for creating and managing your mock endpoints.

Form fields:

| Field | Description | |---|---| | Endpoint Route | Path without /api/ prefix. Supports :param syntax (e.g., users/:id) | | HTTP Method | GET, POST, PUT, PATCH, or DELETE | | Status Code | The HTTP status code the endpoint will return | | Delay (ms) | Optional delay to simulate network latency (e.g., 500 for 500ms) | | JSON Response Body | The body of the response. Supports dynamic variables and Faker hints | | Request Body Schema | Appears for POST, PUT, PATCH. Defines variables from the request body | | Custom Response Headers | Optional JSON object with custom response headers | | Randomize values | Toggle to randomize all values in the response (respecting data types) |

Live cURL Preview: Below the form, a cURL command is generated in real time based on your current form values. You can copy it with one click.

Active Endpoints table:

  • Method badge with semantic colors (green=GET, blue=POST, yellow=PUT, purple=PATCH, red=DELETE)
  • Path, status code, delay, and randomize indicator for each endpoint
  • Filter endpoints by path or method using the search box
  • Edit an existing endpoint — pre-fills the form
  • Delete a single endpoint
  • Export all endpoints to a .rmm file
  • Import endpoints from a .rmm file
  • Reset All — delete all endpoints at once

📋 Request Logs

A live-updating feed of all requests made to your mock endpoints. Refreshes automatically every 3 seconds.

| Column | Description | |---|---| | Time | Timestamp of the request | | Method | HTTP method with color badge | | Path | Full path including /api/ | | Status | HTTP response status code | | Duration | Response time in milliseconds (green < 200ms, yellow < 1s, red ≥ 1s) |

Controls:

  • ⏸ Pause — Stop auto-refresh without losing existing logs
  • ▶ Resume — Resume auto-refresh
  • 🗑 Clear — Delete all stored logs

⚙️ Settings

Reference page with:

  • All server URLs and API endpoints
  • Faker hint cheat sheet
  • CLI command reference
  • Dynamic variable examples

Creating Mock Endpoints

Dynamic Responses with URL Parameters

Use :paramName in the route and reference it in the response body.

Route: products/:productId
Method: GET
Response Body:

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

A GET /api/products/123 request returns:

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

Dynamic Responses with Request Body

Use :fieldName in the response body to echo values from the incoming request body.

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 }
}

A POST /api/users with body { "name": "Ana", "email": "[email protected]" } returns:

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

Faker Hints

Use {{faker.category.method}} placeholders directly in your JSON response body values to generate realistic fake data on every request.

{
  "id": "{{faker.string.uuid}}",
  "name": "{{faker.person.fullName}}",
  "email": "{{faker.internet.email}}",
  "avatar": "{{faker.image.avatar}}",
  "phone": "{{faker.phone.number}}",
  "city": "{{faker.location.city}}",
  "price": "{{faker.commerce.price}}",
  "createdAt": "{{faker.date.recent}}"
}

Every call to this endpoint returns a different set of realistic values.


Delay Simulation

Set a delay (in milliseconds) per endpoint to simulate real-world network latency.

  • 0 — No delay (default)
  • 500 — 500ms delay
  • 2000 — 2 second delay

Useful to test loading states and skeleton UIs in your frontend.


Custom Response Headers

Define custom HTTP headers to be included in the response. Provide a JSON object:

{
  "X-Request-Id": "abc-123",
  "Cache-Control": "no-cache",
  "X-Rate-Limit": "100"
}

OpenAPI Export

The server automatically generates a basic OpenAPI 3.0 specification from all your active endpoints.

Access it at: GET /admin/export/openapi

Or open it directly in your browser: http://localhost:7070/admin/export/openapi

You can paste this JSON into Swagger Editor to visualize and explore your mock API.


Import & Export

Export

Click ⬆ Export in the Admin UI (or use the table toolbar) to download all active endpoints as an endpoints.rmm file (JSON format).

Import

Click ⬇ Import and select a .rmm or .json file previously exported. Duplicate endpoints (same method + path) are skipped automatically.


Admin API Reference

The server exposes an admin REST API used by the UI and CLI:

| Method | Path | Description | |---|---|---| | GET | /admin/endpoints | List all active endpoints | | POST | /admin/endpoint | Create a new endpoint | | PUT | /admin/endpoint | Update an existing endpoint | | DELETE | /admin/endpoint | Delete a single endpoint | | DELETE | /admin/endpoints | Delete ALL endpoints (reset) | | POST | /admin/endpoints/import | Bulk import endpoints | | GET | /admin/logs | Get request logs (?limit=N) | | DELETE | /admin/logs | Clear all request logs | | GET | /admin/export/openapi | Export OpenAPI 3.0 spec |