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-mock-core

v1.6.0

Published

Instant mock REST server from a JSON file. Zero config, zero wait. Built for frontend developers who can't wait for the backend.

Downloads

134

Readme

api-mock-core

Instant mock REST server from a JSON file. Zero config, zero wait.

npm version

CI

License: MIT

Node.js >=16

The Problem

You're building a frontend. The backend isn't ready. You're blocked.

api-mock-core kills that block in one command.


Quick Start

# No installation needed — just run it
npx api-mock-core

# Or scaffold a sample file first
npx api-mock-core init
npx api-mock-core

Your mock server is now live at http://localhost:3000 with full CRUD on all routes defined in api.json.


api.json Format

{
  "/users": [
    { "id": 1, "name": "Alice", "email": "[email protected]", "role": "admin" },
    { "id": 2, "name": "Bob",   "email": "[email protected]",   "role": "user"  }
  ],
  "/products": [
    { "id": "p1", "name": "Widget", "price": 29.99, "stock": 100 }
  ]
}

That's it. Every key is a route. Every value is the initial dataset.


Auto-Generated Endpoints

For every route /resource in your JSON, api-mock-core creates:

| Method | URL | Description | |----------|------------------------|---------------------------------------| | GET | /resource | List all items | | GET | /resource/:id | Get one item by ID | | POST | /resource | Create a new item (auto-generates ID) | | PUT | /resource/:id | Full replace | | PATCH | /resource/:id | Partial update | | DELETE | /resource/:id | Delete item |


Query Parameters

Filtering

GET /users?role=admin
GET /users?name=ali           # case-insensitive substring match
GET /users?role=user&active=true  # multiple filters (AND)

Full-text Search

GET /users?_q=alice           # searches all fields

Sorting

GET /users?_sort=name&_order=asc
GET /products?_sort=price&_order=desc

Pagination

GET /users?_page=1&_limit=10

Pagination headers returned:

  • X-Total-Count — total items matching filters
  • X-Page — current page
  • X-Limit — items per page
  • X-Total-Pages — total pages

CLI Options

Usage: npx api-mock-core [file] [options]

Arguments:
  file                  Path to api.json (default: api.json)

Options:
  -p, --port <number>   Port to listen on (default: 3000)
  -w, --watch           Hot-reload on file changes
  --no-cors             Disable CORS headers
  --open                Open browser automatically
  --no-log              Suppress HTTP access logs
  --quiet               Suppress all non-error output
  --delay <ms>          Add artificial delay to all responses
  --read-only           Disable POST/PUT/PATCH/DELETE (GET only)
  --host <host>         Hostname/IP to bind (default: 0.0.0.0)
  --id-field <field>    Primary key field name (default: id)
  -v, --version         Output version number
  -h, --help            Display help

Pro Options:
  --auth <key>          Require X-API-Key header on all requests
  --share               Expose server via public tunnel URL
  --license <key>       Activate Pro features

Sub-Commands

# Scaffold a sample api.json in current directory
npx api-mock-core init

# Validate your api.json
npx api-mock-core validate api.json

# List all endpoints in a file
npx api-mock-core list api.json

Internal Utility Endpoints

| Endpoint | Description | |----------------|------------------------------------------| | GET /__routes | List all registered endpoints | | GET /__health | Server health check (uptime, memory) | | GET /__version| Version info |


Examples

Hot-reload (edit api.json without restarting)

npx api-mock-core --watch

Custom port

npx api-mock-core --port 4000

Simulate slow network (Pro)

npx api-mock-core --delay 1500

Protect with API key (Pro)

npx api-mock-core --auth my-secret-key
# Client must send: X-API-Key: my-secret-key

Read-only mode (no writes)

npx api-mock-core --read-only

Share with team (Pro)

npx api-mock-core --share
# Prints a public HTTPS URL your whole team can use

Data Behaviour

  • All data lives in memory — it resets when you restart the server
  • POST auto-generates a UUID id if you don't provide one
  • POST / PUT / PATCH automatically add createdAt and updatedAt timestamps
  • PUT fully replaces the item (but preserves the original id)
  • PATCH only updates the fields you send

Pro Features

| Feature | Free | Pro | |-----------------------|----------|----------| | All CRUD endpoints | ✅ | ✅ | | Filtering / sorting | ✅ | ✅ | | Pagination | ✅ | ✅ | | Hot-reload (--watch) | ✅ | ✅ | | API key auth | ✅ | ✅ | | Delay simulation | ≤ 500ms | Unlimited | | Team share (tunnel) | ❌ | ✅ | | Request validation | ❌ | ✅ | | Custom status code | ❌ | ✅ |


Contributing

  1. Fork the repo
  2. npm install
  3. npm test
  4. Open a PR

License

MIT © api-mock-core contributors