pook
HTTP traffic mocking and expectations made easy
What it is and what it does
pook is a Python HTTP mocking library that intercepts traffic from popular HTTP clients and lets you define mock responses using a fluent, chainable API. It works as a decorator, context manager, or direct function call, and supports matching on any HTTP primitive (URL, method, headers, body, query params) with full regex capability. The library includes first-class JSON and XML support via jsonschema and xmltodict, JSON Schema body matching, and can simulate raised errors or network delays.
You can use pook in both unit tests and runtime environments, with configurable mock lifetimes (volatile, persistent, or TTL-limited). It ships with a built-in mock engine supporting multiple HTTP clients, but also supports pluggable third-party engines. With only 3 small dependencies (furl, jsonschema, xmltodict) and no compiled requirements, it installs cleanly and works on Python 3.10+ (CPython and PyPy).
Use it for:
- Mock external API responses in unit tests without making real network calls to third-party services.
- Test error handling by returning specific HTTP status codes and error payloads from mock endpoints.
- Validate request matching logic by asserting that code sends correct headers, query params, or body.
- Test multiple HTTP clients against the same mock definitions in a single test suite.
- Define reusable mock expectations with regex patterns and JSON Schema validation for request bodies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pook intercepts and mocks HTTP traffic for testing, supporting popular Python HTTP clients with a fluent API, regex matching, JSON/XML support, and pluggable mock engines.
Yes. pook is actively maintained, has no known vulnerabilities, low install friction, and a permissive MIT license. It solves a common testing need (HTTP mocking) with a clean API that works across multiple HTTP clients. Install it if you need to mock HTTP traffic in tests and want flexibility in matching and response definition.
Install
pook on PyPI
pip
pip install pookuv
uv add pookpoetry
poetry add pookInstalling pook
Before you install
Low friction: pure Python wheel with only 3 runtime dependencies (furl, jsonschema, xmltodict). Actively maintained with last commit 2026-03-11.
License in practice
MIT license (permissive) means you can use pook freely in commercial and private projects with minimal restrictions; attribution is appreciated but not legally required.
Quickstart
pip install pook
import pook
@pook.on
def test_api():
mock = pook.get('http://example.com/api', reply=200, response_json={'status': 'ok'})
assert mock.calls == 0
Requires Python 3.10 or later (CPython or PyPy); only recent versions of supported HTTP clients are tested.
Verify before relying
- Whether network delay simulation (mentioned for aiohttp) is fully functional or experimental.
- Specific version constraints for runtime dependencies (furl, jsonschema, xmltodict) beyond pip resolution.
- Real-world compatibility with HTTP client versions newer than those tested.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — furl, jsonschema, xmltodict |
| Maintenance | actively maintained — 161 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 270,323/month — #8,237 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pook-2.1.6-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
urllib3-mockMocks urllib3 HTTP requests in tests by…
permissive · top 15,000 on PyPI
httmockIntercepts and mocks HTTP requests made by the…
permissive · top 5,000 on PyPI
wiremockPython client library for interacting with…
permissive · top 15,000 on PyPI
responsesMocks HTTP requests made by the requests…
permissive · top 1,000 on PyPI
mocketMocket is a socket mocking framework that…
permissive · top 15,000 on PyPI
respxRESPX mocks HTTPX and HTTP Core libraries for…
permissive · top 1,000 on PyPI
smithy-httpProvides HTTP primitives, interfaces, and…
permissive · top 15,000 on PyPI
snappi-ixnetworkExecutes traffic generation test scripts…
permissive · top 15,000 on PyPI
aiointerceptIntercepts aiohttp client requests by routing…
permissive · top 15,000 on PyPI
aws-lambda-contextProvides the AWS Lambda Context class for type…
permissive · top 15,000 on PyPI