Local APIs from OpenAPI
Build the frontend. Don’t wait for the backend.
Counterfact turns an OpenAPI document into a useful local API in one command. Point your frontend at localhost and start building against generated responses before the real backend is ready.
Start with your OpenAPI document
npx counterfact@latest https://petstore3.swagger.io/api/v3/openapi.json apiRequires Node.js 22+. For a repeatable project or CI workflow,install a pinned versionand commit the lockfile.
Quick start
A useful API before you write a handler
Run the command
Counterfact reads the document, writes editable routes and generated types, then starts a server.
Point the frontend at localhost
The base URL is
http://localhost:3100. A browser app can make an ordinary request:const response = await fetch("http://localhost:3100/pet/1"); const pet = await response.json();Get a generated response
Supported operations return schema-derived sample data immediately. For example:
{ "id": 1, "name": "string", "status": "available" }
The defaults are a useful starting point for frontend work and exploration—not a claim that your backend behavior is complete.
When your frontend needs more
Replace a generated response with a custom handler when a screen needs a specific case. Add only the state, failures, latency, proxying, or tests that the workflow needs.