HTTPX2

A next-generation Python HTTP client with sync and async APIs, HTTP/2 support, and a built-in command-line client.

Library
PyPI
v2.12.0
928stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
79/100Good
Development Activity100
Maintenance100
Community56
Maturity20
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
87/100Excellent
Architecture88
Code Quality88
Innovation84
Learning Curve86

HTTPX2 is a fully featured, next-generation HTTP client library for Python. It offers both synchronous and asynchronous APIs, supports HTTP/1.1 and HTTP/2, and ships with an integrated command-line client — all behind an interface that feels familiar to Requests users.

HTTPX2 is Pydantic’s maintained continuation of the widely used HTTPX project. With HTTPX seeing limited recent activity, Pydantic has taken stewardship to provide a reliably maintained path forward — including timely security updates for a library that sits in the critical path of countless production systems — while honoring the original project’s design.

What You Get

  • Synchronous Client and asynchronous AsyncClient sharing one API
  • HTTP/1.1 and HTTP/2 protocol support
  • A Requests-compatible top-level API (get, post, etc.)
  • Connection pooling, cookies, redirects, and explicit timeout configuration
  • Streaming request and response bodies
  • An optional integrated command-line HTTP client

Common Use Cases

  • Calling REST and HTTP APIs from synchronous scripts and services
  • Making concurrent requests in async applications with AsyncClient
  • Talking to HTTP/2 endpoints for multiplexed connections
  • Streaming large downloads or uploads without buffering everything in memory
  • Making quick ad-hoc requests from the terminal with the built-in CLI

Under The Hood

Architecture — HTTPX2 is layered around a Client (sync) and AsyncClient (async) that manage connection pooling, cookies, redirects, and configuration, delegating the actual byte-level transport to a pluggable transport layer (HTTPTransport/AsyncHTTPTransport) backed by the httpcore engine. Request and Response objects wrap the underlying protocol, with streaming bodies handled lazily. HTTP/2 support is provided through an optional h2-based transport, and the same request-building code path serves both sync and async call styles.

Tech Stack — Pure Python (src layout under src/httpx2) built on httpcore for connection management, certifi for CA bundles, idna for internationalized hostnames, and sniffio/anyio for async-runtime detection. Packaging uses a modern pyproject.toml with optional extras for the CLI (click, rich, pygments) and HTTP/2 (h2); docs are built with mkdocs.

Code Quality — The project carries a substantial test suite (roughly 68 test modules under tests/) exercised by a CI test-suite workflow, inheriting the mature, well-typed codebase of the original HTTPX. Pydantic has taken stewardship specifically to keep it stable and security-patched given its position in the critical path of many production systems.

API Design — The top-level API is deliberately requests-compatible — httpx2.get(), .post(), and a Client context manager feel familiar to anyone coming from Requests — while adding first-class async, explicit timeouts, and typed configuration. An optional integrated command-line client and extensive documentation make it approachable for both quick scripts and production services.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search