httpx
The next generation HTTP client
When Python's async ecosystem matured around FastAPI and asyncio, developers needed an HTTP client that could keep up. The requests library is synchronous-only โ calling it inside an async function blocks the entire event loop. httpx was built to be the modern, async-capable successor.
httpx has two modes: a synchronous Client that works exactly like requests, and an AsyncClient you use inside async with. Both share the same API, so you can switch between them or gradually migrate without rewriting business logic.
Introduction
Now, let's get started:
Or, using the command-line client.Use it when
Use httpx when building FastAPI or asyncio applications that call external APIs. Also reach for it when you need HTTP/2 support, a requests-compatible API with async support, or a single library that works in both sync and async contexts.
Skip it when
For simple synchronous scripts where you already use requests, there's little reason to switch โ requests has a larger ecosystem of auth libraries and middleware. For high-volume async scraping at scale, aiohttp's lower-level control may be more efficient.
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.