Skip to content

Repository files navigation

httpware

PyPI versionSupported Python versionsDownloadsCoverageCILicenseGitHub starsContext7uvRuffty

Typed, resilient HTTP clients for Python — typed errors, typed response bodies, and composable resilience (retry, bulkhead, circuit breaker), sync or async.

Why httpware

  • Errors you can catch by name — a 404 raises NotFoundError, a 429 RateLimitedError, automatically; everything else bubbles up under one httpware.StatusError base. No raise_for_status(), no status-code branching.
  • Typed response bodiesresponse_model=User decodes the body straight to your pydantic or msgspec type; a missing decoder fails fast, before the request goes out.
  • Composable resilience — retry + retry-budget, bulkhead, circuit breaker, and timeout as middleware over standard httpx2.

Built on httpx2: httpware re-exports httpx2.Request/httpx2.Response and stays a thin wrapper, not a new HTTP abstraction.

Status: Pre-1.0. Public API is subject to change between minor releases until v1.0.

Install

pip install httpware # core only — no decoder
pip install httpware[pydantic] # + PydanticDecoder — BaseModel, dataclasses, primitives, generics
pip install httpware[msgspec] # + MsgspecDecoder — Struct, dataclasses, primitives, generics
pip install httpware[pydantic,msgspec] # both — BaseModel routes to pydantic, Struct to msgspec
pip install httpware[all] # everything (pydantic, msgspec, otel)

Quickstart

A typed GET against a live API (needs pip install httpware[pydantic]):

importasynciofromhttpwareimportAsyncClientfrompydanticimportBaseModelclassUser(BaseModel):
id: intname: strasyncdefmain() ->None:
asyncwithAsyncClient(base_url="https://jsonplaceholder.typicode.com") asclient:
user=awaitclient.get("/users/1", response_model=User)
print(user.name) # Leanne Grahamasyncio.run(main())

The sync Client is identical — swap AsyncClientClient and drop the await / async with. A 4xx/5xx response raises a typed StatusError; a malformed body raises DecodeError. Both subclass httpware.ClientError.

Documentation

Full guides live at httpware.modern-python.org:

  • Quickstart & observability — resilience middleware, streaming, and the stable logger/event contract.
  • Middleware — write your own (auth, tracing, request-ID propagation).
  • Resilience — retry + retry-budget, bulkhead, circuit breaker, timeout.
  • Errors — the exception tree and catching strategies.
  • Testinghttpx2.MockTransport injection.
  • Recipes — DI wiring, phase-decorator patterns, link-header pagination.

🗒️ Release notes · 📦 PyPI · 📝 License

Part of modern-python

Browse the full list of templates and libraries in modern-python — see the org profile for the categorized index.

About

Python HTTP client framework with sync & async clients and built-in resilience

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Sponsor this project

Contributors

Languages