Introduction
yRest is a zero-config REST API mock server for frontend developers. It reads a db.yml file and automatically exposes a full CRUD REST API — including relations, query parameters, pagination, SSE streams and custom static routes — with no backend needed.
npx @yrest/cli serve db.yml# → REST API at http://localhost:3070For a version-by-version history of what’s been added and what’s on the roadmap, see the Changelog and Releases on GitHub.
When to use it
Section titled “When to use it”- You’re building a frontend and need a realistic API before the backend is ready.
- You need a predictable mock for integration tests (Vitest, Playwright, Cypress).
- You want to demo a UI flow without maintaining a real server.
- You need SSE or custom endpoint behaviour that
json-servercan’t handle. - You’re designing a new API contract before the backend team starts building — yRest gives you a real running server to validate the exact shape, not just a static spec document.
- You need to test error states, conditional auth flows, or network latency — simulate them with conditional scenarios and delay injection, no server code required.
How it compares
Section titled “How it compares”Both yRest and json-server share the same zero-config philosophy — point them at a data file and get a REST API instantly. The difference is how far each one goes. yRest extends the model with a richer relation system, typed query operators, SSE streams, conditional mock scenarios, and a full programmatic API. If json-server covers your needs, keep using it. If you’ve hit its limits, yRest is the next step.
| Feature | yRest | json-server |
|---|---|---|
| Foundation | ||
| Zero config | ||
| Full CRUD | ||
| YAML database | ||
| Query & Filtering | ||
Field operators (_gte, _like, _regex…) | ||
Field projection (_fields) | ||
| Pageable mode (envelope response) | ||
| Relations | ||
| Relations: many2one, one2one, many2many | ||
Auto-embedding (_nested: true) | ||
| Mock features | ||
Custom routes (_routes) | ||
Template variables ({{}params.id}}) | ||
| Conditional scenarios | ||
| Handler functions (JS logic) | ||
| SSE stream routes | ||
| Snapshot endpoints | ||
| Integration & tooling | ||
| Programmatic API for test frameworks | ||
| OpenAPI 3.0 export | ||
| TypeScript types | ||
Install
Section titled “Install”yRest can be used in two ways depending on your workflow.
As a dev-server — run it with npx alongside your frontend app, no installation required. See Quick Start for a step-by-step walkthrough.
npx @yrest/cli serve db.yml # zero-install, API ready at http://localhost:3070Or install it as a dev dependency to skip the npx download on every run:
npm install -D @yrest/clinpx @yrest/cli init # scaffold db.yml + yrest.config.ymlnpx @yrest/cli serve db.ymlAs a programmatic test fixture — import createYrestServer directly into your Vitest, Playwright or Cypress suite. No separate process, no CLI. See Programmatic API for the full API reference.
import { createYrestServer } from "@yrest/cli";
const server = createYrestServer({ file: "./tests/db.yml", port: 3070 });await server.start();// run tests ...await server.stop();