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

@idirdev/fakeapi

v1.0.0

Published

Generate fake REST API data with realistic content

Readme

fakeapi

[EN] Instant mock REST API server from a JSON file or directory — full CRUD, filtering, CORS, delay simulation and read-only mode. [FR] Serveur API REST factice instantané depuis un fichier JSON ou un répertoire — CRUD complet, filtrage, CORS, simulation de délai et mode lecture seule.


Features / Fonctionnalités

[EN]

  • Serves any JSON file or directory of JSON files as a REST API automatically
  • Full CRUD: GET, POST, PUT, PATCH, DELETE on every resource collection
  • Query-string filtering, sorting and pagination on GET list endpoints
  • Configurable response delay to simulate network latency (--delay)
  • CORS headers enabled with a single flag (--cors)
  • Read-only mode prevents all write operations (--read-only)
  • Writes changes back to the source JSON file (persistent mutations)
  • Auto-generates UUID-based IDs for new POST items

[FR]

  • Expose automatiquement n'importe quel fichier JSON ou répertoire de fichiers JSON comme API REST
  • CRUD complet : GET, POST, PUT, PATCH, DELETE sur chaque collection de ressources
  • Filtrage, tri et pagination par chaîne de requête sur les endpoints de liste GET
  • Délai de réponse configurable pour simuler la latence réseau (--delay)
  • En-têtes CORS activés avec un seul drapeau (--cors)
  • Le mode lecture seule empêche toutes les opérations d'écriture (--read-only)
  • Écrit les modifications dans le fichier JSON source (mutations persistantes)
  • Génère automatiquement des IDs basés sur UUID pour les nouveaux éléments POST

Installation

npm install -g @idirdev/fakeapi

CLI Usage / Utilisation CLI

# Serve db.json as REST API / Exposer db.json comme API REST
fakeapi db.json

# Custom port and host / Port et hôte personnalisés
fakeapi db.json --port 4000 --host 0.0.0.0

# Enable CORS and add 300ms latency / Activer CORS et ajouter 300ms de latence
fakeapi db.json --cors --delay 300

# Read-only mode (no POST/PUT/DELETE) / Mode lecture seule (pas de POST/PUT/DELETE)
fakeapi db.json --read-only

# Serve a directory of JSON files / Exposer un répertoire de fichiers JSON
fakeapi ./fixtures/

Example Output / Exemple de sortie

fakeapi at http://localhost:3000
Resources: users, posts, comments

# GET list with filter / Liste GET avec filtre
curl http://localhost:3000/users?role=admin
[{"id":"a1b2c3","name":"Alice","role":"admin"}]

# GET single item / Élément unique GET
curl http://localhost:3000/users/a1b2c3
{"id":"a1b2c3","name":"Alice","role":"admin"}

# POST new item / Nouvel élément POST
curl -X POST http://localhost:3000/users \
  -H "Content-Type: application/json" \
  -d '{"name":"Bob","role":"editor"}'
{"id":"f4e5d6","name":"Bob","role":"editor"}

# DELETE / Supprimer
curl -X DELETE http://localhost:3000/users/f4e5d6
{"id":"f4e5d6","name":"Bob","role":"editor"}

API (Programmatic) / API (Programmation)

const { createServer, FakeApiServer } = require('@idirdev/fakeapi');

// Quick start / Démarrage rapide
const server = createServer('db.json', {
  port: 3001,
  host: 'localhost',
  delay: 200,    // 200ms simulated latency / latence simulée 200ms
  cors: true,
  readOnly: false,
});
server.start(); // fakeapi at http://localhost:3001

// Using the class directly / Utiliser la classe directement
const api = new FakeApiServer('./fixtures/', { port: 5000, cors: true });
api.start();

db.json example / Exemple de db.json

{
  "users":  [{ "id": 1, "name": "Alice", "role": "admin" }],
  "posts":  [{ "id": 1, "title": "Hello", "userId": 1 }],
  "tags":   [{ "id": 1, "label": "node" }]
}

License

MIT — idirdev