Builds zero-code REST mock servers with JSON Server: watch mode, custom routes, filtering, pagination, and CRUD persistence for rapid prototyping.
Agentic Workflow: Read -> Reason -> Act (api-mock-json)
You are Api Mock Json (testing) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — testing context for api-mock-json
- Domain: Builds zero-code REST mock servers with JSON Server: watch mode, custom routes, filtering, pagination, and CRUD persistence for rapid prototyping.
- json-server: Serve a mock REST API from a JSON database file —
npm install -g json-server
- route-customization: Map custom URLs and add middleware to the mock server —
curl -s http://localhost:3001/users/1 | jq .
- Check
knowledge and prerequisites: prism, wiremock, msw
2. Reason — think for api-mock-json
- For
json-server: Serve a mock REST API from a JSON database file — decide which checks to run
- For
route-customization: Map custom URLs and add middleware to the mock server — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-mock-json tools
- Tools:
Glob, Grep, Read, Bash, Json-server (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-mock-json:1facaef5
API Mock v2 - JSON Server
Instant REST mocks from a JSON file.
What This Skill Does
- Serves CRUD endpoints for each collection in db.json
- Provides filtering, pagination, and sorting via query params
- Persists mutations back to the db file in watch mode
When to Use
- Rapid UI prototyping against REST shapes
- Quick contract demos before the real backend exists
- Local frontend development with fake data
Real Commands
npm install -g json-server
json-server --watch db.json --port 3001
curl -s http://localhost:3001/users | jq 'length'
curl -s -X POST http://localhost:3001/users -H 'Content-Type: application/json' -d '{"name":"alice"}'
db.json Example
{
"users": [{ "id": 1, "name": "alice", "role": "admin" }],
"orders": []
}
Endpoints: GET/POST /users, GET/PUT/PATCH/DELETE /users/:id.
Testing
- Query filters: /users?role=admin
- Pagination: /users?_page=2&_limit=5
- Sorting: /users?_sort=name&_order=asc
- Full-text: /users?q=ali
Best Practices
- Commit db.json with seed data for reproducibility
- Use routes.json to simulate nested or custom paths
- Do not use JSON Server in production traffic
Capabilities
json-server
Serve a mock REST API from a JSON database file
Parameters:
port (integer): Port for the mock server, default 3000
db-file (string): JSON file containing collections to serve
routes-file (string): Custom route mapping file (routes.json)
Commands:
npm install -g json-server
json-server --watch db.json --port 3001
json-server db.json --routes routes.json --port 3001
curl -s http://localhost:3001/users | jq 'length'
curl -s -X POST http://localhost:3001/users -H 'Content-Type: application/json' -d '{"name":"alice"}'
Examples:
route-customization
Map custom URLs and add middleware to the mock server
Commands:
curl -s http://localhost:3001/users/1 | jq .
curl -s -X PUT http://localhost:3001/users/1 -H 'Content-Type: application/json' -d '{"name":"bob"}'
curl -s -X DELETE http://localhost:3001/users/1 -o /dev/null -w '%{http_code}\n'
Examples:
References
1---2name: "api-mock-json"3description: "Builds zero-code REST mock servers with JSON Server: watch mode, custom routes, filtering, pagination, and CRUD persistence for rapid prototyping. Use when working with json server, route customization or when the user mentions json server, route customization."4license: "MIT"5compatibility: "Requires prism, wiremock, msw, node.js, python. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-mock-json8 author: Kdesk9 version: 2.0.010 category: testing11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(json-server:*) Bash(npm:*)"12---1314Builds zero-code REST mock servers with JSON Server: watch mode, custom routes, filtering, pagination, and CRUD persistence for rapid prototyping.1516## Agentic Workflow: Read -> Reason -> Act (api-mock-json)1718You are **Api Mock Json** (testing) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — testing context for `api-mock-json`21- Domain: Builds zero-code REST mock servers with JSON Server: watch mode, custom routes, filtering, pagination, and CRUD persistence for rapid prototyping.22- **json-server**: Serve a mock REST API from a JSON database file — `npm install -g json-server`23- **route-customization**: Map custom URLs and add middleware to the mock server — `curl -s http://localhost:3001/users/1 | jq .`24- Check `knowledge` and `prerequisites: prism, wiremock, msw`2526### 2. Reason — think for `api-mock-json`27- For `json-server`: Serve a mock REST API from a JSON database file — decide which checks to run28- For `route-customization`: Map custom URLs and add middleware to the mock server — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-mock-json` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Json-server` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-mock-json:1facaef5`3536# API Mock v2 - JSON Server3738Instant REST mocks from a JSON file.3940## What This Skill Does41- Serves CRUD endpoints for each collection in db.json42- Provides filtering, pagination, and sorting via query params43- Persists mutations back to the db file in watch mode4445## When to Use46- Rapid UI prototyping against REST shapes47- Quick contract demos before the real backend exists48- Local frontend development with fake data4950## Real Commands5152```bash53npm install -g json-server54json-server --watch db.json --port 300155curl -s http://localhost:3001/users | jq 'length'56curl -s -X POST http://localhost:3001/users -H 'Content-Type: application/json' -d '{"name":"alice"}'57```5859## db.json Example6061```json62{63 "users": [{ "id": 1, "name": "alice", "role": "admin" }],64 "orders": []65}66```6768Endpoints: GET/POST /users, GET/PUT/PATCH/DELETE /users/:id.6970## Testing71- Query filters: /users?role=admin72- Pagination: /users?_page=2&_limit=573- Sorting: /users?_sort=name&_order=asc74- Full-text: /users?q=ali7576## Best Practices77- Commit db.json with seed data for reproducibility78- Use routes.json to simulate nested or custom paths79- Do not use JSON Server in production traffic8081## Capabilities8283### json-server84Serve a mock REST API from a JSON database file8586**Parameters:**87- `port` (integer): Port for the mock server, default 300088- `db-file` (string): JSON file containing collections to serve89- `routes-file` (string): Custom route mapping file (routes.json)9091**Commands:**92- `npm install -g json-server`93- `json-server --watch db.json --port 3001`94- `json-server db.json --routes routes.json --port 3001`95- `curl -s http://localhost:3001/users | jq 'length'`96- `curl -s -X POST http://localhost:3001/users -H 'Content-Type: application/json' -d '{"name":"alice"}'`9798**Examples:**99- json-server --watch db.json --port 3001 serves full REST endpoints100- curl -s 'http://localhost:3001/users?_page=2&_limit=5' exercises built-in pagination101- curl -s 'http://localhost:3001/users?role=admin' uses query filtering102103### route-customization104Map custom URLs and add middleware to the mock server105106**Commands:**107- `curl -s http://localhost:3001/users/1 | jq .`108- `curl -s -X PUT http://localhost:3001/users/1 -H 'Content-Type: application/json' -d '{"name":"bob"}'`109- `curl -s -X DELETE http://localhost:3001/users/1 -o /dev/null -w '%{http_code}\n'`110111**Examples:**112- -cli --help113- -api --help114115## References116- [json-server GitHub](https://github.com/typicode/json-server)117- [jq Manual](https://jqlang.github.io/jq/manual/)