Skip to content
routebase

2.0 API Mocking

API mocking that starts frontend work on day one

Routebase generates realistic mock APIs from the spec on a stable URL, so API mocking starts before the backend exists.

14-day Pro trial — no credit card required.

A Routebase mock server for API mocking: the rule tree grouped by folder on the left, the mock URL with analytics for rules, requests and endpoint coverage in the centre, and a live request log on the right.

API mocking is the step most teams skip, because keeping a hand-written mock in sync with a changing backend costs more than it saves. Routebase generates the mock server from your OpenAPI spec instead, so the frontend gets a stable mock URL on day one. Rules generated from a draft follow it as you edit, and rules pinned to a published version flag every change in the spec for review. The responses use realistic synthetic data rather than placeholder strings, and stateful rules carry what one request wrote into the next one until you reset them. You can also rehearse the bad days with latency, error, and timeout simulation, while proxy mode forwards the routes you have not mocked to the real API. Because the same spec runs your tests and docs, an API mock in Routebase is never a second copy of the contract that someone has to maintain.

API mocking straight from the spec

Generating from a specification creates one rule per endpoint, and each rule answers with the success response the spec documents, filled with generated data. Every project gets one mock server on its own address under routebasemock.dev, with CORS and preflight requests handled for the browser. Generating again skips the rules that already exist.

  • One rule per endpoint, editable rule by rule
  • Static, dynamic, fixture and Smart Mock response bodies
  • An optional access token for the mock URL

Data that looks real

Placeholders fill a response with realistic values in English, German, French or Spanish, and a response can echo what the request sent. A stateful rule stores what one call wrote, so the next call returns it until you reset the state.

  • {{faker.*}} placeholders for names, emails, addresses and more
  • Request values like {{request.body.name}}
  • State kept per rule until you reset it
  • Fixtures as response bodies, with pipes like where, pluck and random

Rehearse the bad days

Each rule can add a fixed delay plus a random extra, fail at a probability you set, or enforce a rate limit. A failure is a 500, 502, 503 or 504, a timeout that holds the connection for 30 seconds, or a reset connection. Over the limit, the mock answers 429 with Retry-After and rate limit headers, which is exactly what your client has to handle.

  • Fixed delay plus a random extra per rule
  • 500, 502, 503, 504, timeouts and connection resets at a set probability
  • Limits per second, minute or hour, answered with 429 and Retry-After

Proxy what you don't mock

On Starter and above, proxy mode forwards every request that matches no rule to the real API, so you mock the new endpoint and let the rest pass through. Rules match on method, path, query and headers, and the highest priority wins when several match. The live request log shows each call the mock received and keeps it for 30 days.

  • Proxy mode for unmatched requests, on Starter and above
  • Matching on method, path, query and headers, highest priority first
  • Live request log, kept for 30 days

Frequently asked questions

How does API mocking work in Routebase?

Routebase generates mock rules from the endpoints in your OpenAPI spec and serves them on one address per project. Rules generated from a draft follow it as you edit, and rules pinned to a published version flag a changed spec so you can review and sync them. Nobody maintains a hand-written mock server on the side.

Can I mock an API before the backend exists?

Yes, that is the point. The frontend builds against the mock URL from day one, with realistic synthetic data in every response, and switches to the real API when it ships.

Can the mock simulate errors and slow responses?

Yes. A fixed delay plus a random extra, failures as 500, 502, 503 or 504, timeouts, connection resets and per-rule rate limits let you rehearse the failures your frontend must survive before they happen in production.

What happens to endpoints I have not mocked?

On Starter and above, proxy mode forwards any request that matches no rule to the real API, so a partly mocked API still answers every route. The live request log shows every call the mock received.

One living spec

The rest of the lifecycle

Every stage below works from the same spec, so a change is made once and published once.

Ready to ship on it?

Routebase is live. Design your API once — docs, mocks, tests, and monitoring all follow from the same source.

14-day Pro trial — no credit card required.