A local mock API server generator for fast frontend and integration prototyping.
Project description
MockAPI
Generate and run local mock API servers from small JSON/YAML specs.
MockAPI is a terminal-first mock API generator for frontend development, integration testing, demos, and API contract prototyping. It turns compact JSON/YAML specs into working Flask routes, can generate REST-style resource specs with realistic Faker data, previews route responses without starting a server, validates duplicate routes and status codes, and exports OpenAPI documents for downstream tooling.
- Spec-driven mock servers - run GET, POST, PUT, PATCH, DELETE, OPTIONS, and HEAD routes from JSON or YAML.
- REST resource generation - scaffold list, detail, create, update, patch, and delete endpoints with realistic sample data.
- Dynamic response templates - use placeholders such as
{{ name }},{{ uuid }},{{ body.email }}, and{{ path.id }}. - OpenAPI export - turn a mock spec into a portable OpenAPI 3 document.
- Fast local previews - inspect, validate, and request mock responses directly from the CLI.
- Clean terminal output - Rich tables, panels, syntax highlighting, and readable validation errors.
Installation
pip install mockapi-cli
The installed console command is:
mockapi --help
Usage
Create a starter spec:
mockapi init mockapi.yaml --resource users
Generate a richer resource:
mockapi generate shop.yaml --resource products --field id:id --field name:word --field price:float --field in_stock:bool
Inspect and validate it:
mockapi inspect shop.yaml
mockapi validate shop.yaml
Preview a route without starting a server:
mockapi request shop.yaml GET /products/42
mockapi request shop.yaml POST /products --body '{"name":"Keyboard","price":89.9}'
Run the local API:
mockapi serve shop.yaml --port 8080
Export an OpenAPI document:
mockapi openapi shop.yaml --output openapi.json
Commands
| Command | Description | Example |
|---|---|---|
mockapi init [path] |
Create a starter YAML spec. | mockapi init mockapi.yaml --resource users |
mockapi generate <output> |
Generate CRUD-style REST routes with fake data. | mockapi generate api.yaml --resource orders --count 10 |
mockapi serve <spec> |
Start a Flask mock API server. | mockapi serve api.yaml --port 8080 |
mockapi inspect <spec> |
Show API metadata and route summaries. | mockapi inspect api.yaml |
mockapi validate <spec> |
Validate methods, paths, status codes, and duplicate routes. | mockapi validate api.yaml |
mockapi sample <resource> |
Generate fake records as JSON or a table. | mockapi sample users --field email:email --count 3 |
mockapi request <spec> <method> <path> |
Render a mock response without a server. | mockapi request api.yaml GET /orders/1 |
mockapi openapi <spec> |
Export an OpenAPI 3 document. | mockapi openapi api.yaml -o openapi.json |
mockapi export <spec> |
Normalize and convert a spec to JSON or YAML. | mockapi export api.yaml --to json -o api.json |
Configuration
MockAPI specs are plain YAML or JSON files. A route includes an HTTP method, path, status code, optional headers, and response body.
name: Example API
version: 1.0.0
cors: true
routes:
- method: GET
path: /users/{id}
status: 200
response:
id: "{{ path.id }}"
name: "{{ name }}"
email: "{{ email }}"
- method: POST
path: /users
status: 201
response:
id: "{{ uuid }}"
email: "{{ body.email }}"
Supported placeholder sources include Faker fields ({{ name }}, {{ email }}, {{ city }}), generated values ({{ uuid }}, {{ int }}, {{ bool }}), request body fields ({{ body.name }}), query parameters ({{ query.page }}), headers ({{ headers.Authorization }}), and route parameters ({{ path.id }}).
License
MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mockapi_cli-0.1.0.tar.gz.
File metadata
- Download URL: mockapi_cli-0.1.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ccda1dbbeac66a1f4a3d7fde49dda866c76fc3e97a113bc759e747bdc7a3e0f
|
|
| MD5 |
901d6ae0d09cb509e8304ddb4ff67b8f
|
|
| BLAKE2b-256 |
4ee65e207d89ead38186aaa355370a860707ba00cee160473b0471e7c8d2b3a9
|
File details
Details for the file mockapi_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mockapi_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e48aef4358604a1f3b2ef316d993ca0ea087a1df0eb84aec240a9d6bad42065b
|
|
| MD5 |
fc16708d7374528630f7cdd70f7dd934
|
|
| BLAKE2b-256 |
bce5b879876553bf0e4742f3c17ca276fa67c1de5f440003cdca518ab8b483bc
|