Pythonaiohttpv3.13.5
PythonBeginner-friendly

aiohttp

Async http client/server framework (asyncio)

asyncasynciohttp-clienthttp-serverwebwww/http
The Problem

When Python's asyncio became stable, the synchronous requests library became a liability in async applications โ€” every HTTP call blocked the event loop, defeating the point of async. aiohttp was one of the first libraries to provide both an async HTTP client and a full async HTTP server built on asyncio.

Mental Model

aiohttp runs entirely on asyncio's event loop. The client uses async with session.get(url) as response to make requests that yield control back to the loop while waiting for the network. The server side uses a similar pattern โ€” request handlers are coroutines that the server dispatches concurrently without threads.

60-second start

Install aiohttp

pip install aiohttp
import aiohttp

Use it when

Use aiohttp when you need a battle-tested async HTTP client or server, especially in applications that make many concurrent HTTP calls (scrapers, API aggregators) or build lightweight async web services. It has a mature ecosystem and is widely used in production.

Skip it when

For new async API projects, FastAPI (built on Starlette/uvicorn) has better developer ergonomics, automatic validation, and docs. For synchronous scripts, requests is simpler. httpx offers a compatible API with both sync and async modes if you want flexibility.

Alternatives
httpxSupports both sync and async; requests-compatible API; easier migration path from synchronous code
fastapiBetter choice for building async HTTP servers โ€” more ergonomic with automatic OpenAPI docs
trioAlternative async runtime that some find more intuitive; aiohttp doesn't support trio natively

Ready to explore the full API?

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