Skip to main content

Resilience-first async HTTP client framework for Python

Project description

httpware

Test PyPI version Python versions License: MIT

Async HTTP client framework for Python.

httpware is a thin opinionated wrapper around httpx2. It re-exports httpx2.Request/httpx2.Response, adds a middleware chain composed at client construction, supports opt-in typed response decoding (pydantic and msgspec are both extras), and raises a status-keyed exception tree automatically on 4xx/5xx. It also ships a small resilience suite — Retry middleware with a Finagle-style RetryBudget, plus a Bulkhead concurrency limiter — under httpware.middleware.resilience.

Status: Pre-1.0. Public API is subject to change between minor releases until v1.0. Streaming and observability are not yet shipped.

Install

pip install httpware                # core only — no decoder
pip install httpware[pydantic]      # + PydanticDecoder (the default-decoder path)
pip install httpware[msgspec]       # + MsgspecDecoder
pip install httpware[all]           # everything declared above (pydantic, msgspec)

AsyncClient() with no decoder= argument defaults to constructing a PydanticDecoder; that path requires the pydantic extra and raises ImportError at AsyncClient.__init__ if it is missing.

Quickstart

Requires: pip install httpware[pydantic]

from httpware import AsyncClient
from pydantic import BaseModel


class User(BaseModel):
    id: int
    name: str


async def main() -> None:
    async with AsyncClient(base_url="https://api.example.com") as client:
        user = await client.get("/users/1", response_model=User)
        print(user.name)

With resilience middleware

Compose resilience middleware at construction; Bulkhead goes outside Retry so one slot covers all retry attempts.

from httpware import AsyncClient, Bulkhead, Retry


async def main() -> None:
    async with AsyncClient(
        base_url="https://api.example.com",
        middleware=[
            Bulkhead(max_concurrent=10),  # cap total in-flight
            Retry(),                       # default: 3 attempts, full-jitter backoff
        ],
    ) as client:
        user = await client.get("/users/1", response_model=User)

Errors

All 4xx/5xx responses raise typed exceptions automatically: NotFoundError, ServiceUnavailableError, RateLimitedError, etc. — all subclasses of httpware.StatusError. Transport-layer transient failures raise NetworkError; the resilience middleware raise RetryBudgetExhaustedError and BulkheadFullError. Everything inherits httpware.ClientError.

🗒️ 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httpware-0.4.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httpware-0.4.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file httpware-0.4.0.tar.gz.

File metadata

  • Download URL: httpware-0.4.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for httpware-0.4.0.tar.gz
Algorithm Hash digest
SHA256 676e2a04fc5fc783db7e09045938a8c5d7dd23577c623dabdeb77101044feb36
MD5 7111fc66515fa18e156c3f6608766935
BLAKE2b-256 f6385f2adde4fba6a56a6fd21acb8d795f02b0484c6ed2dfb13a9a3e2fa75885

See more details on using hashes here.

File details

Details for the file httpware-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: httpware-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for httpware-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6107d287c37733d595873dbe93fc978c1bf57abce54a0fe701f456fca3c5b043
MD5 17e0c08f1a903a84a4c77476b895e48e
BLAKE2b-256 f2a8b3c41d49ea56930228c2692fb861a6aefcbbd2b1705be7850d1205083ece

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page