Flaky integration tests? Record the API once, replay it forever

A test that passes at 9am and fails at 11am because a shared staging server hiccuped is worse than no test. VCR-style recording turns live API interactions into a cassette you can replay identically on every run - no network, no drift, no flakes.

Last updated: 2026-08-23 · APIGhost on GitHub

Honest scope: APIGhost reads an OpenAPI 3.0/3.1 spec and serves generated mocks or recorded cassettes locally. It does not proxy or transform production traffic, and it is not on public PyPI - install from source below.
pip install git+https://github.com/Coding-Dev-Tools/apighost.git

Not on public PyPI; the self-hosted index is currently unavailable. The git+ form above is the documented working pip path. Homebrew also works: brew tap Coding-Dev-Tools/homebrew-tap && brew install apighost.

Why mocks drift and tests flake

Hand-written fixtures go stale the moment the API contract moves. Shared staging environments add latency, rate limits, and data that other people change under you. The result is the classic flake: same code, different answer.

The fix is to make the HTTP layer a constant. Record the request/response pairs once, commit the cassette to your repo, and replay it in CI and local runs. Your tests then exercise your code against byte-identical responses every time.

Record once, replay forever

# Capture interactions into a named cassette
apighost record petstore.yaml

# Replay the exact recorded responses
apighost replay my-recording -p 8080

Fitting cassettes into CI

- name: Run integration tests against recorded cassette
  run: |
    apighost replay my-recording -p 8080 &
    sleep 2
    pytest tests/integration/

Because the replay server is local and offline, CI needs no secrets, no staging credentials, and no network access to third parties. When the OpenAPI contract changes, regenerate the mock from the spec, re-record, review the cassette diff alongside your code diff.

Pricing

TierPriceIncludes
Free$0Unlimited local use, 100 requests/session
Pro$12/mo ($119/yr)Unlimited requests, VCR cassettes, CI/CD integration
Suite$49/mo ($39 billed annually)All Coding-Dev-Tools tools under one license

MIT-licensed source, Python 3.10+.

Do cassettes replace mocking entirely?

No - they complement it. Use apighost serve with scenarios when you need edge-case behaviors you have not observed yet; use record/replay when you want a frozen, deterministic copy of known-good behavior.

Does replay need the original OpenAPI spec?

No. replay takes only the cassette. The spec matters when generating or re-recording.

Try it

Clone or pip-install from source and point record at any OpenAPI spec you already have:

APIGhost on GitHub