aiohttp
Async http client/server framework (asyncio)
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.
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.
Install aiohttp
pip install aiohttp
import aiohttpUse 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.
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.