A terminal TUI for defining REST mock endpoints while serving them locally.
Project description
Termimock
Termimock is a terminal API mock server with a TUI. Define mock REST endpoints from your terminal while the HTTP server is already running, then point your frontend at it immediately.
Most mock tools make you switch to a GUI, export config, or restart a process. Termimock keeps the control panel and the mock server together in one terminal session.
Features
- Live local HTTP server and terminal UI in the same process
- Add, edit, duplicate, delete, enable, and disable mock endpoints
- Match by HTTP method and path
- Custom status code, content type, response body, and headers
- Path parameters such as
/api/users/:idor/api/users/{id} - Response templates such as
{{params.id}},{{query.q}},{{method}}, and{{path}} - Per-route latency simulation
- Multiple responses per route with
first,cycle, orrandomselection - JSON request body matching with fields like
emailoruser.email - Request log visible inside the TUI
- Built-in browser GUI at
/_termimock - Save and load endpoint definitions as JSON
- Hot reload route files while the server is running
- Import starter routes from OpenAPI JSON
- Headless mode for CI, demos, and scripted frontend work
- Zero runtime dependencies
Install
python3 -m pip install -e .
After the package is published to PyPI:
pipx install termimock
or:
python3 -m pip install termimock
Run the TUI
termimock
By default the server listens on http://127.0.0.1:8080.
termimock --host 127.0.0.1 --port 9000 --file examples/sample-routes.json
Run Without the TUI
termimock --headless --file examples/sample-routes.json
Open the built-in GUI:
http://127.0.0.1:8080/_termimock
The GUI lets you add, edit, duplicate, delete, enable, disable, and save routes from a browser while the mock server keeps running.
Route files reload automatically when changed. Use --no-watch to disable that behavior.
Import OpenAPI
Generate a starter route file from an OpenAPI JSON document:
termimock --import-openapi openapi.json --file routes.json
Then run it:
termimock --file routes.json
Then test it:
curl http://127.0.0.1:8080/api/user
Try a templated route:
curl "http://127.0.0.1:8080/api/users/42?tab=settings"
If port 8080 is already busy, choose another port:
termimock --headless --port 9000 --file examples/sample-routes.json
TUI Shortcuts
| Key | Action |
|---|---|
a |
Add endpoint |
e |
Edit selected endpoint |
d |
Delete selected endpoint |
c |
Clone selected endpoint |
space |
Enable or disable selected endpoint |
s |
Save routes |
r |
Reload routes from disk |
j / k or arrows |
Move selection |
q |
Quit |
Route File Format
{
"routes": [
{
"method": "GET",
"path": "/api/user",
"status": 200,
"content_type": "application/json",
"headers": {
"X-Mock": "termimock"
},
"body": "{\"id\":1,\"name\":\"Ada\"}",
"delay_ms": 0,
"enabled": true
}
]
}
Path parameters can use either :id or {id} syntax. Response bodies can reference {{params.id}}, {{query.name}}, {{method}}, and {{path}}.
Routes can also define response variants:
{
"method": "GET",
"path": "/api/flaky",
"response_mode": "cycle",
"responses": [
{
"status": 200,
"content_type": "application/json",
"headers": {},
"body": "{\"ok\":true}"
},
{
"status": 500,
"content_type": "application/json",
"headers": {},
"body": "{\"ok\":false}"
}
]
}
POST routes can match JSON request bodies:
{
"method": "POST",
"path": "/api/login",
"body_match": {
"email": "admin@test.com"
},
"body": "{\"token\":\"dev-token\",\"email\":\"{{body.email}}\"}"
}
Project Status
This is an early, hackable version meant to prove the idea cleanly. Good next features are latency simulation, path parameters, request body matching, response presets, import from OpenAPI, and a richer route editor.
Development
PYTHONPATH=src python3 -m unittest discover -s tests
Releases
GitHub Releases are created from version tags. A release builds and attaches the Python wheel and source archive.
git tag v0.1.0
git push origin v0.1.0
Publishing a GitHub Release also publishes the package to PyPI through Trusted Publishing.
Container Package
Termimock publishes a container image to GitHub Container Registry.
docker run --rm -p 8080:8080 ghcr.io/homiyano/termimock:main
Open the GUI at:
http://127.0.0.1:8080/_termimock
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 termimock-0.1.0.tar.gz.
File metadata
- Download URL: termimock-0.1.0.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c90a3dd8c9e1bfdcf788be01715f82961feca1a9ea470ed5571e2d73c348691
|
|
| MD5 |
e53bfb92af9b07420cc532bccb64131b
|
|
| BLAKE2b-256 |
a2e224e66245a803d67502d97f2c7c5aa6f4db1ab8af16953f034962f4f4de17
|
Provenance
The following attestation bundles were made for termimock-0.1.0.tar.gz:
Publisher:
pypi.yml on homiyano/termimock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
termimock-0.1.0.tar.gz -
Subject digest:
0c90a3dd8c9e1bfdcf788be01715f82961feca1a9ea470ed5571e2d73c348691 - Sigstore transparency entry: 1574411563
- Sigstore integration time:
-
Permalink:
homiyano/termimock@dda88021619e2b9f71a605436b5a32d37dd6378c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/homiyano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@dda88021619e2b9f71a605436b5a32d37dd6378c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file termimock-0.1.0-py3-none-any.whl.
File metadata
- Download URL: termimock-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39ed8f93a4d5915c9004aad4fa8ca875e9840d094acb823f0a8c02fe05ed7bfc
|
|
| MD5 |
7e9a2e4d6818c49accf0545687a48efb
|
|
| BLAKE2b-256 |
8d4545c5c866b82d6e2f3a915e50edfb65acc4545b3b152024c857d3e8a3dd5c
|
Provenance
The following attestation bundles were made for termimock-0.1.0-py3-none-any.whl:
Publisher:
pypi.yml on homiyano/termimock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
termimock-0.1.0-py3-none-any.whl -
Subject digest:
39ed8f93a4d5915c9004aad4fa8ca875e9840d094acb823f0a8c02fe05ed7bfc - Sigstore transparency entry: 1574411580
- Sigstore integration time:
-
Permalink:
homiyano/termimock@dda88021619e2b9f71a605436b5a32d37dd6378c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/homiyano
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@dda88021619e2b9f71a605436b5a32d37dd6378c -
Trigger Event:
workflow_dispatch
-
Statement type: