Python library that implements async HTTP clients and servers on top of asyncio, with optional WebSockets, middleware, and pluggable routing.
Overview
aiohttp provides both sides of HTTP for asyncio-based Python programs: an async client for outbound requests and a web server for inbound traffic. It is meant to be imported into application code rather than run as a standalone product.
On the client, you work through a session object that performs non-blocking GET, POST, and related calls. Optional aiodns integration speeds DNS resolution. On the server, you define an application, attach routes, and can handle ordinary HTTP as well as WebSocket conversations without nested callback chains.
Server features include middleware, signals, and flexible routing tables. Client code can attach middleware to customize how requests and responses are processed. The stack builds on multidict, yarl, and frozenlist, with optional Brotli compression support when those extras are installed.
You install the package with pip and embed it in your own services or scripts. Community discussion happens on GitHub, Matrix, and Stack Overflow; the project maintains backward-compatibility policies for public APIs.
Key features
- Async HTTP client and server
- WebSocket client and server support
- Pluggable routing and middleware
- Client middleware hooks
- Optional fast DNS via aiodns
- Multipart and streaming utilities
- Web server signals
Use cases
- Async web APIs in Python
- Non-blocking HTTP client jobs
- WebSocket chat or push endpoints
- Replacing blocking HTTP in asyncio apps