interposition-http-adapter
HTTP adapter for Interposition.
Serves recorded HTTP interactions from an Interposition Cassette as a real HTTP server, allowing you to replay captured API responses for testing and development.
Installation
pip install interposition-http-adapter
Usage
InterpositionHttpAdapter is an ASGI application (based on Starlette) that replays HTTP interactions through an Interposition Broker.
from interposition import (
Broker,
Cassette,
Interaction,
InteractionRequest,
ResponseChunk,
)
import uvicorn
from interposition_http_adapter import InterpositionHttpAdapter
# 1. Build an InteractionRequest describing the HTTP request to match
request = InteractionRequest(
protocol="http",
action="GET",
target="/api/data",
headers=(),
body=b"",
)
# 2. Build ResponseChunks with status_code in the first chunk's metadata
response_chunks = (
ResponseChunk(
data=b'{"message": "hello"}',
sequence=0,
metadata=(("status_code", "200"),),
),
)
# 3. Create a Cassette containing the interaction
interaction = Interaction(
request=request,
fingerprint=request.fingerprint(),
response_chunks=response_chunks,
)
cassette = Cassette(interactions=(interaction,))
# 4. Create a Broker in replay mode
broker = Broker(cassette=cassette, mode="replay")
# 5. Create the adapter and serve it
app = InterpositionHttpAdapter(broker=broker)
uvicorn.run(app, host="127.0.0.1", port=8000)
Once the server is running, a GET request to http://127.0.0.1:8000/api/data returns the recorded response with status code 200 and body {"message": "hello"}.
The adapter supports all standard HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS). Requests that do not match any recorded interaction return a 500 Internal Server Error response.
Creating from a Cassette file
If you have a Cassette saved as a JSON file, you can create an adapter directly:
import uvicorn
from interposition_http_adapter import InterpositionHttpAdapter
app = InterpositionHttpAdapter.from_cassette_file("fixtures/api.json")
uvicorn.run(app, host="127.0.0.1", port=8000)
API Reference
Detailed documentation is available in MkDocs: https://osoekawaitlab.github.io/interposition-http-adapter/.
CLI
The package provides a command-line interface:
interposition_http_adapter --version
License
MIT
Metadata
Release files for interposition-http-adapter 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| interposition_http_adapter-0.4.0.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| interposition_http_adapter-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / interposition_http_adapter-0.4.0.tar.gz
| Download URL | interposition_http_adapter-0.4.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ca45497635215e0b31229bcebda38c5738ffbb14d4d38c2acd4c2eae28e15ef
|
|
BLAKE2b-256 checksum How to use checksums |
cfbe5df291598b781d3091e10fe351e8afc65998b1fff020f74d9a1a723a2415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 27, 2026.
Transparency logRelease files / interposition_http_adapter-0.4.0-py3-none-any.whl
| Download URL | interposition_http_adapter-0.4.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eac07b73b5c861fd60119f2f751103f901897cb61bd40bb860cb95e61f28b089
|
|
BLAKE2b-256 checksum How to use checksums |
4932c3caa41dbe5d4ffa73b1e898e5257554df5775984a10dc608f6bd418e60c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 27, 2026.
Transparency log