api-mock
Serve fake API responses from a YAML definition file with Faker.js data and configurable latency. Use when you need to develop a frontend without a backend, test error states, simulate slow APIs, or do contract-first API development. Triggers include "mock API", "fake backend", "stub API", "YAML mock server", "frontend without backend", "simulate API", "API contract testing".
Best use case
api-mock is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Serve fake API responses from a YAML definition file with Faker.js data and configurable latency. Use when you need to develop a frontend without a backend, test error states, simulate slow APIs, or do contract-first API development. Triggers include "mock API", "fake backend", "stub API", "YAML mock server", "frontend without backend", "simulate API", "API contract testing".
Teams using api-mock should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/api-mock/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How api-mock Compares
| Feature / Agent | api-mock | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Serve fake API responses from a YAML definition file with Faker.js data and configurable latency. Use when you need to develop a frontend without a backend, test error states, simulate slow APIs, or do contract-first API development. Triggers include "mock API", "fake backend", "stub API", "YAML mock server", "frontend without backend", "simulate API", "API contract testing".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# api-mock
Serve realistic fake API responses from a YAML file. Hot reloads on file change. Web dashboard included.
## When to use
- Frontend development without a backend
- Testing error states and edge cases (404, 500, payment declined)
- Contract-first API development (define the API shape, build against it)
- Demos that need realistic data
- CI/CD tests that need a predictable API
## Installation
```bash
npm install -g @your-org/api-mock-server
```
## Quick Start
```bash
# Create api-mock.yaml
cat > api-mock.yaml << 'EOF'
endpoints:
- method: GET
path: /api/users
status: 200
body:
users:
- id: "{{faker.string.uuid}}"
name: "{{faker.person.fullName}}"
email: "{{faker.internet.email}}"
EOF
# Start the server
api-mock start
# Server: http://127.0.0.1:3100
# Dashboard: http://127.0.0.1:3101
```
## YAML Schema
```yaml
endpoints:
- method: GET # HTTP method
path: /api/users/:id # Path (Express-style params)
status: 200 # Response status code
latency: 50 # Delay in ms (default: 0)
headers:
Content-Type: application/json
body:
id: "{{params.id}}"
name: "{{faker.person.fullName}}"
scenarios:
- name: not-found
status: 404
body:
error: "Not found"
```
## Faker Templates
| Template | Example output |
|---|---|
| `{{faker.string.uuid}}` | `550e8400-e29b-41d4-a716-...` |
| `{{faker.person.fullName}}` | `Alice Johnson` |
| `{{faker.internet.email}}` | `alice@example.com` |
| `{{faker.date.recent}}` | `2025-01-10T14:33:00.000Z` |
| `{{faker.commerce.price}}` | `49.99` |
| `{{faker.number.int min=1 max=100}}` | `42` |
| `{{params.id}}` | URL param value |
| `{{body.fieldName}}` | Request body field |
| `{{query.page}}` | Query string value |
## Scenario Activation
```bash
# Persistent (via dashboard or API)
curl -X POST http://127.0.0.1:3101/api/scenarios/GET%20%2Fapi%2Fusers%2F%3Aid \
-H 'Content-Type: application/json' \
-d '{"scenario": "not-found"}'
# Per-request (does not persist)
curl http://127.0.0.1:3100/api/users/42?__scenario=not-found
```
## CLI Reference
| Command | Description |
|---|---|
| `api-mock start [file]` | Start mock server (default: api-mock.yaml) |
| `api-mock start --port 3200` | Override mock server port |
| `api-mock start --dashboard 3201` | Override dashboard port |
| `api-mock start --latency 100` | Add global latency to all responses |
| `api-mock validate [file]` | Validate YAML without starting server |
| `api-mock --help` | Show help |
| `api-mock --version` | Show version |
## Environment Variables
| Variable | Description | Default |
|---|---|---|
| `MOCK_PORT` | Mock server port | `3100` |
| `MOCK_DASHBOARD_PORT` | Dashboard port | `3101` |
| `MOCK_CONFIG` | Path to YAML config | `api-mock.yaml` |
| `MOCK_LATENCY` | Global latency in ms | `0` |
| `MOCK_LOG_RETENTION` | Request log retention days | `3` |
| `MOCK_ALLOW_REMOTE` | Allow remote connections (0 or 1) | `0` |
## Troubleshooting
### "config file not found"
Create `api-mock.yaml` in the current directory, or pass the path: `api-mock start path/to/config.yaml`.
### Template rendered as literal string
Check that template syntax uses double curly braces: `{{faker.string.uuid}}`. Single braces or backtick-style won't be recognized.
### Endpoint returns 404 with "no mock defined"
The path doesn't match any defined endpoint. Check the method and path pattern in your YAML. Use `:param` for dynamic segments.Related Skills
Skill: Uptime Monitoring
## Overview
Skill: Status Page
## Overview
Skill: unit-conversion
## Overview
Skill: recipe-scaler
## Overview
reading-list
Operate the reading-list API to save, manage, tag, search, and export articles.
email-digest
Configure, test, and troubleshoot the reading-list daily email digest delivered via nodemailer.
websocket-realtime
Use the WebSocket connection in poll-builder to receive live vote updates. Use when you need to stream real-time poll results, monitor a poll for new votes, or build a live dashboard. Triggers include "live results", "real-time updates", "stream votes", "watch poll", or "WebSocket".
poll-builder
Self-hosted poll creation tool with real-time results. Use when you need to create a poll, check vote counts, close a poll, export results, or get the shareable link for a poll. Triggers include "create poll", "vote", "poll results", "survey", "collect votes", "share poll", or any task involving polling or voting.
Skill: personal-finance
## Overview
Skill: csv-import
## Overview
Skill: Syntax Highlighting
## Purpose
Skill: Pastebin Core
## Purpose