Every frontend and integration test needs a mock API. Hardcoding responses breaks the moment a field changes, and hand-written mocks drift as soon as the spec updates.
APIGhost is the Python option for that gap. Point it at an OpenAPI 3.x spec and it starts a mock server in one command. Fake data uses property-name hints, so email fields get emails and id fields get IDs.
pip install git+https://github.com/Coding-Dev-Tools/apighost.git
apighost serve petstore.yaml
APIGhost is not on public PyPI. If you use Homebrew, the tap is also available: brew tap Coding-Dev-Tools/homebrew-tap && brew install apighost.
Most mock servers are either hand-maintained JSON or generated once and forgotten. When the spec changes, the mocks do not. APIGhost generates endpoints directly from the spec. Add a field to the schema, rerun the serve command, and the new field is there.
Deterministic tests need deterministic responses. apighost record captures real responses. apighost replay serves the same JSON every time.
apighost record petstore.yaml --output fixtures/cassette.json
apighost replay fixtures/cassette.json -p 8080
APIGhost ships with named scenario presets. Add an error scenario once and flip to it with a flag:
apighost serve spec.yaml --scenario error
You can also create custom scenarios.
Free tier covers local and dev use. Pro is $12/mo ($119/yr) for unlimited requests, VCR cassettes, and CI integration. Suite is $49/mo for all Coding-Dev-Tools tools under one license.
The Getting started guide covers the full CI walkthrough — GitHub Actions, pytest examples, and scenario switching in automation.
MIT, Python 3.10+.