Skip to content

counterfact/api-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3,767 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Counterfact


MIT License Coverage Status friction 0%

Mock servers work—until you need state, failures, or control mid-run.

Static responses aren’t enough. There’s no shared state. You can’t inject failures. You can’t test real workflows.
Mock servers make it easy to get started, but hard to keep going.
Counterfact is an API simulator without those limits.

Point it at an OpenAPI document and get a live, stateful API in seconds.

  • Type-safe TypeScript handlers for every endpoint
  • Hot reloading as you edit
  • Shared state across routes
  • A built-in REPL to control behavior at runtime
  • Optional proxying to real backends

Flexbile for humans. Stable for AI agents.

You’re in control—without restarting.

For a frontend developer waiting on a backend,
a test engineer who needs clean, reproducible state,
or an AI agent that needs a stable API

Real enough to be useful. Fake enough to be usable.

Try it now

npx counterfact@latest https://petstore3.swagger.io/api/v3/openapi.json api

Starts a local server with a live REPL to inspect and control API behavior
Requires Node ≥ 22.0.0

Go deeper

  • Getting started – Detailed walkthrough with state, REPL, and proxy
  • Patterns – How Counterfact transforms your workflow
  • Example repo – Using Counterfact to implement the Swagger Petstore
  • How it compares – json-server, WireMock, Prism, Microcks, MSW
  • Usage – Explore features and how to use them
  • Reference$ API, CLI flags, architecture
  • FAQ – State, types, regeneration

About

Not just a mock server. Turn an OpenAPI spec into TypeScript-based simulation, with state management, hot reload, and a REPL.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors