Pythonhttpxv0.28.1
PythonIntermediate

httpx

The next generation HTTP client

httpasyncasynciohttp2api-clientwww/httppythontrio
The Problem

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.

Mental Model

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.

60-second start

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.

Alternatives
requestsSimpler, more mature, larger ecosystem โ€” use it when async isn't needed
aiohttpMore battle-tested for high-concurrency async use cases; more control over the connection pool

Ready to explore the full API?

See every class, function, and relationship in an interactive graph.