HTTPX is a Python HTTP client with sync and async APIs, HTTP/1.1 and HTTP/2, and an optional command-line client. It targets Python 3.9 and later and installs via pip.
Overview
HTTPX is a Python library for issuing HTTP requests and handling responses in application code. It offers a familiar request-oriented API alongside support for asynchronous workflows, so the same package can serve both traditional scripts and async services.
The client speaks HTTP/1.1 and HTTP/2 and can talk directly to WSGI or ASGI applications without going over the network. It includes strict timeout handling, type annotations, and many behaviors found in popular HTTP clients, such as connection pooling, cookie sessions, proxy support, streaming downloads, and common authentication modes.
Optional extras add HTTP/2, SOCKS proxies, Brotli and Zstd decoding, and a CLI built on Click with Rich terminal output. Install the base package with pip, or add bracket extras for those capabilities.
Documentation covers quick start, advanced usage, async patterns, HTTP/2, and a full developer API reference. Third-party packages can integrate with HTTPX as noted in the project docs.
Key features
- Sync and async request APIs
- HTTP/1.1 and HTTP/2 support
- Requests-compatible API shape
- Optional command-line client
- WSGI and ASGI direct calls
- Connection pooling and cookies
- Proxy and SOCKS support
- Strict timeouts and type hints
Use cases
- HTTP calls in Python applications
- Async web service outbound requests
- Testing ASGI apps in-process
- Quick requests from the terminal
- Scripts needing HTTP/2 or compression extras