The MarkApiDown mock server reads theDocumentation Index
Fetch the complete documentation index at: https://docs.markapidown.net/llms.txt
Use this file to discover all available pages before exploring further.
## Expected response blocks in your spec files and serves them over HTTP — no live backend required. Point your frontend application, mobile client, or integration test suite at the mock server and develop against stable, spec-controlled responses.
What the mock server does
Every spec file inapi-docs/apis/ contains an ## Expected response section that records what the API should return. mad mock reads those blocks and serves them as real HTTP responses on a local port. Requests to the mock server are matched by HTTP method and path — path parameters such as /users/:id are matched loosely, so any value for :id returns the same recorded response body.
The mock server does not make any outbound HTTP requests. It only reads from your spec files.
Start the mock server
Runmad mock from your project root:
4001 and reads specs from the api-docs/ directory in the current working tree.
http://localhost:4001 and all requests are served from the recorded expected responses.
Options
| Flag | Default | Description |
|---|---|---|
--port | 4001 | TCP port to listen on |
--latency | none | Artificial response delay in milliseconds added to every response |
[dir] | api-docs | Path to the api-docs/ root directory containing spec files |
Use
--latency to simulate slow network conditions such as a mobile device on a 3G connection or a geographically distant API server. Setting --latency=1000 adds a one-second delay to every response, which helps you discover loading states, timeout handling, and user experience issues before they appear in production.Mock mode in the browser UI
Start the browser UI in mock mode with the--mock flag:
## Expected response block from the spec instead of making a real HTTP request. A MOCK badge appears on every response card and a mock chip appears in the top navigation bar so you always know you are looking at recorded data.
Mock mode in the browser uses the same ## Expected response blocks as mad mock, so the two share the same source of truth — your spec files.
Browser mock mode vs standalone mock server
mad serve --mock | mad mock | |
|---|---|---|
| Use case | Interactive review and debugging in the browser | Frontend app or integration tests point to a mock HTTP URL |
| Backend traffic | None | None |
| Port | Same as the browser UI (default 8080) | Separate port (default 4001) |
| Latency simulation | No | Yes (--latency) |
| Requires browser | Yes | No |
mad serve --mock when you are actively reviewing specs in the browser. Use mad mock when your application code needs a real HTTP server to talk to.
When to use the mock server
Frontend development
Start the mock server alongside your frontend dev server. Your UI code can call real
fetch requests against http://localhost:4001 without a backend running.CI without external services
Run integration tests in CI against the mock server. No staging credentials, VPN, or live service dependency needed — tests are fast and deterministic.
Demos and presentations
Use the mock server to demo an API integration before the backend is built. Responses are stable, predictable, and safe to show publicly.
Offline development
Work on API integrations without internet access. The mock server runs entirely from local spec files.
How responses are served
When a request arrives at the mock server:- MarkApiDown matches the request method and path against all spec files in
api-docs/apis/. - For the matching spec, it reads the
## Expected responsesection. - It parses the HTTP status line, headers, and body from that block.
- It returns those values as a real HTTP response, with any configured
--latencydelay added.
404 with a JSON body describing the unmatched route.
If a spec has an empty ## Expected response block (a stub {}), the mock server returns 200 OK with an empty JSON object. Fill in the expected response block with realistic field names and values to get useful mock responses.
How to populate expected responses
The fastest way to populate## Expected response blocks is to run mad exec against a live server once and copy the response body into the spec manually:
## Expected response section of the spec file, then commit it. From that point on, the mock server and mad serve --mock both return that recorded response.