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

fake-api-cli

v0.1.0

Published

Generate realistic fake REST APIs in seconds.

Readme

fake-api-cli

npm Node TypeScript License PRs Status


✨ Features

  • ⚡ Generate complete REST APIs in seconds
  • 📦 Zero database setup
  • 👤 Built-in generators for common resources
  • 🧩 Custom schema-based resource generation
  • 🔗 Resource references (@users.id)
  • 🏗 Nested objects
  • 📚 Arrays
  • 💾 Automatic JSON persistence
  • 🔍 Filtering
  • 📄 Pagination
  • ↕ Sorting
  • 🔎 Search
  • 🎯 Field selection
  • 🔄 Full CRUD support
  • 🖥 Simple CLI
  • 📖 Swagger UI
  • 📝 Written entirely in TypeScript

Why fake-api?

Frontend developers often need an API before the backend is ready.

Instead of manually creating JSON files or spinning up a database, fake-api generates a realistic REST API with configurable resources, relationships, and fake data.

Perfect for:

  • Frontend development
  • UI prototyping
  • Hackathons
  • Portfolio projects
  • Testing REST clients
  • Learning API integration

Installation

Install globally

npm install -g fake-api-cli

Or use directly with NPX

npx fake-api-cli start

Quick Start

Create a configuration file.

export default {
  port: 3000,

  persistence: true,

  database: "./fake-api-db.json",

  resources: {
    users: {
      count: 100,
      schema: {
        name: "person.fullName",
        email: "internet.email",
        city: "location.city",
      },
    },
  },
};

Start the server.

fake-api start

Output

✔ Fake API Server Started

URL:
http://localhost:3000

Resources:
• /users

Swagger:
/docs

Now open

http://localhost:3000/users

You'll instantly have a fully working REST API.


Example Response

[
  {
    "id": 1,
    "name": "John Doe",
    "email": "[email protected]",
    "city": "London"
  },
  {
    "id": 2,
    "name": "Alice Smith",
    "email": "[email protected]",
    "city": "Paris"
  }
]

Supported HTTP Methods

| Method | Endpoint | Description | | ------ | ------------ | ----------------------- | | GET | /users | Get all records | | GET | /users/:id | Get a single record | | POST | /users | Create a record | | PUT | /users/:id | Replace a record | | PATCH | /users/:id | Update part of a record | | DELETE | /users/:id | Delete a record |


Built-in Resources

Out of the box, fake-api includes generators for:

  • Users
  • Products
  • Posts

Example

resources: {
  users: {
    count: 100,
  },

  products: {
    count: 50,
  },

  posts: {
    count: 25,
  },
}

Need something else?

Just define a schema and fake-api generates it automatically.


Custom Schema Generation

Create completely custom resources without writing generators.

resources: {
  books: {
    count: 5,

    schema: {
      title: "book.title",
      author: "person.fullName",
      pages: "number.int(100,500)",
    },
  },
}

Output

{
  "id": 1,
  "title": "The Hobbit",
  "author": "Jane Doe",
  "pages": 341
}

Nested Objects

schema: {
  name: "person.fullName",

  address: {
    city: "location.city",
    country: "location.country",
  },
}

Result

{
  "name": "John",

  "address": {
    "city": "London",
    "country": "United Kingdom"
  }
}

Arrays

skills: [
  "helpers.arrayElement(React,Node,Go)",
  "helpers.arrayElement(TypeScript,Rust,Python)"
]

Produces

{
  "skills": [
    "React",
    "TypeScript"
  ]
}

🔗 Resource References

Resources can reference records from other resources using the @resource.field syntax.

Example

resources: {
  users: {
    count: 100,
    schema: {
      name: "person.fullName",
    },
  },

  posts: {
    count: 200,
    schema: {
      title: "lorem.sentence",
      userId: "@users.id",
    },
  },
}

Generated output

{
  "id": 1,
  "title": "My First Post",
  "userId": 42
}

References are randomly selected from existing records.

They can also be used inside arrays.

friends: [
  "@users.id",
  "@users.id"
]

Result

{
  "friends": [14, 87]
}

🔍 Query Parameters

Every generated resource automatically supports powerful query operations.

Pagination

GET /users?page=1&limit=10

Sorting

Ascending

GET /users?sort=name

Descending

GET /users?sort=-name

Multiple fields

GET /users?sort=city,-name

Filtering

Equality

GET /users?city=London

Not equal

GET /users?city_ne=London

Greater than

GET /products?price_gt=100

Greater than or equal

GET /products?price_gte=100

Less than

GET /products?price_lt=500

Less than or equal

GET /products?price_lte=500

IN operator

GET /users?role_in=Admin,Manager

Search

Search across supported fields.

GET /users?search=john

Field Selection

Return only selected fields.

GET /users?fields=id,name,email

Response

[
  {
    "id": 1,
    "name": "John Doe",
    "email": "[email protected]"
  }
]

💾 Persistence

When persistence is enabled, all changes are automatically written to a JSON database.

export default {
  persistence: true,

  database: "./fake-api-db.json",
}

Supported operations:

  • POST
  • PUT
  • PATCH
  • DELETE

Changes are immediately persisted to disk.


📖 Swagger UI

Every server exposes interactive API documentation.

http://localhost:3000/docs

Swagger allows you to:

  • Explore endpoints
  • Execute requests
  • View responses
  • Test CRUD operations

No additional configuration required.


🖥 CLI

Start the server

fake-api start

Using NPX

npx fake-api-cli start

Development

npm run dev -- start

Build

npm run build

⚙ Configuration

A typical configuration file looks like this.

export default {
  port: 3000,

  delay: 0,

  persistence: true,

  database: "./fake-api-db.json",

  auth: false,

  resources: {
    users: {
      count: 100,

      schema: {
        name: "person.fullName",
        email: "internet.email",
        city: "location.city",
      },
    },
  },
}

📁 Project Structure

fake-api/

├── src/
│   ├── cli/
│   ├── config/
│   ├── controllers/
│   ├── database/
│   ├── generators/
│   ├── query/
│   ├── routes/
│   ├── server/
│   ├── services/
│   ├── types/
│   └── utils/
│
├── dist/
├── package.json
└── README.md

🛣 Roadmap

v0.x

  • ✅ CRUD API
  • ✅ Query Engine
  • ✅ Built-in generators
  • ✅ Custom schema generation
  • ✅ Nested objects
  • ✅ Arrays
  • ✅ Resource references
  • ✅ Persistence
  • 🚧 Request validation
  • 🚧 Better Swagger generation
  • 🚧 Seeded data generation
  • 🚧 API authentication
  • 🚧 Response delay simulation

v1.0

  • Stable API
  • Production-ready documentation
  • Improved CLI
  • Comprehensive testing
  • OpenAPI improvements

🤝 Contributing

Contributions are welcome.

If you'd like to improve fake-api, feel free to:

  1. Fork the repository
  2. Create a new branch
  3. Commit your changes
  4. Open a Pull Request

Bug reports, feature requests, and discussions are always appreciated.


📄 License

This project is licensed under the MIT License.

See the LICENSE file for details.


⭐ Support the Project

If you find fake-api useful, consider giving the repository a ⭐ on GitHub.

It helps the project reach more developers and motivates future development.


Made with ❤️ by Pabitra Maity