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

@nazariazargul/api-mocker

v1.0.3

Published

CLI tool to mock REST endpoints from OpenAPI specifications

Readme

API Mocker

A command-line tool to generate mock REST APIs from OpenAPI/Swagger specifications. This tool helps frontend developers by providing realistic mock data based on your API specification.

Features

  • Generate mock REST APIs from OpenAPI 3.0/Swagger specifications
  • Support for path parameters and query parameters
  • Realistic mock data generation based on schema types and formats
  • Built-in Swagger UI for API documentation
  • CORS support for cross-origin requests
  • Automatic handling of different response status codes

Installation

# Install globally
npm install -g @nazariazargul/api-mocker

Usage

# Basic usage
api-mocker --path path/to/openapi.yaml --port 3000

# Options
api-mocker --help

Command Line Options

  • --path, -s: Path to OpenAPI specification file (default: './openapi.yaml')
  • --port, -p: Port to run the mock server on (default: 3000)

Mock Data Generation

The tool generates realistic mock data based on the OpenAPI schema:

  • Strings: Random strings with format support (date, date-time, email, uri, uuid)
  • Numbers: Random numbers within specified ranges
  • Integers: Random integers within specified ranges
  • Booleans: Random true/false values
  • Arrays: 1-3 random items by default
  • Objects: All properties mocked according to their schemas
  • Enums: Random selection from specified values
  • Patterns: Basic regex pattern support

Example

  1. Create an OpenAPI specification file (e.g., api.yaml):
openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths:
  /users/{id}:
    get:
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  name:
                    type: string
                  email:
                    type: string
                    format: email
  1. Run the mock server:
api-mocker --path api.yaml --port 3000
  1. Access your mock API:
  • API Endpoints: http://localhost:3000/users/123
  • Swagger UI: http://localhost:3000/api-docs

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT