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 🙏

© 2025 – Pkg Stats / Ryan Hefner

api-mock-smart

v1.0.1

Published

Smart OpenAPI/Swagger-based mock API server with realistic data generation.

Readme

api-mock-smart

Smart OpenAPI/Swagger-based mock API server with intelligent data generation.

api-mock-smart reads your OpenAPI/Swagger 3 specification and spins up a mock API server with realistic fake data, in‑memory persistence, and full CRUD endpoints.


📦 Installation

Install as a dev dependency (recommended):

npm install -D api-mock-smart

Or install globally:

npm install -g api-mock-smart

Node.js 18+ is required.


🚀 Quick Start

CLI

Start a mock server from an OpenAPI spec file:

npx api-mock-smart start ./openapi.yaml --port 3000

Common options:

  • --port, -p: Port to run the server on (default: 3000)
  • --delay, -d: Fixed response delay in milliseconds (default: 0)
  • --watch, -w: Watch the spec file and reload on changes

Examples:

# Basic usage
api-mock-smart start ./api.yaml

# Custom port and delay
api-mock-smart start ./api.yaml --port 4000 --delay 200

# Watch mode for development
api-mock-smart start ./api.yaml --watch

🧩 Programmatic Usage

Use api-mock-smart from your tests or Node.js app:

import { mockAPI } from "api-mock-smart";

const server = await mockAPI("./openapi.yaml", {
  port: 3000,
  delay: 100,
});

await server.start();
console.log("Mock server running on http://localhost:3000");

// Later...
await server.stop();

Basic options:

  • port: Server port (default 3000)
  • delay: Fixed delay in ms (default 0)

⚙️ Configuration (optional)

You can create an api-mock-smart.config.js file in your project root to customize generators, delays, and error rates:

module.exports = {
  generators: {
    customerId: () => `CUST-${Math.random().toString(36).slice(2, 9)}`,
  },
  delay: { min: 100, max: 500 }, // variable delay
  errorRate: 0.05,               // 5% random error responses
};

📝 License

MIT