# aiohttp — card for AI agents

Async HTTP client/server framework for Python with WebSocket support.

Category: HTTP clients and networking · PyPI package `aiohttp` · latest version 3.14.5 (checked 2026-11-01)
Install: `pip install aiohttp`
License: Apache-2.0 AND MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## aiohttp
- Make requests inside `async with aiohttp.ClientSession() as session:`, open each response with `async with session.get(...) as response:`, and `await response.text()` for the body.
- Do not create a `ClientSession` outside of an event loop; the docs FAQ calls this dangerous.
- Install `aiohttp[speedups]`, or at least `aiodns`, which the docs call highly recommended for DNS speed.
- Run with `python -X dev` during development. aiohttp then uses a strict client parser and adds extra warnings.
- Treat `DeprecationWarning` from aiohttp as a to-do. Deprecated APIs are kept for at least a year and a half, then can go away.
- For servers, register handlers with `app.add_routes([web.get(...)])` and start with `web.run_app(app)`. For WebSockets, create `web.WebSocketResponse()` and `await ws.prepare(request)` before reading messages.
- On 3.14.4 and later, raise `client_max_fields` on `web.Application` if forms can exceed 1000 fields; otherwise they get a 413.

## What it is
- aiohttp is an "Asynchronous HTTP client/server framework for asyncio and Python". The GitHub repository was created on 2013-10-01 and is Apache-2.0 licensed. The docs say it is written mostly by Nikolay Kim and Andrew Svetlov. The current version is 3.14.4.
- There are two halves. On the client side, you open a `ClientSession` with `async with`, make requests from it, and `await` the response body. On the server side, you write `async` handler functions, register them on a `web.Application` with `add_routes`, and start it with `web.run_app`. WebSocket handlers live in the same app as regular routes.
- It is for Python code that already runs on asyncio and needs to make HTTP calls, serve them, or both. The README links a page for people "coming from requests" that explains why the async version takes more lines.

## Caveats
- More code than requests: The README and docs point people coming from requests to a page titled "why we need so many lines". The session and the response are both opened with `async with` blocks.
- Fast DNS is a separate install: aiodns is optional, but the README calls it "highly recommended for sake of speed". Brotli compression on the client also needs an extra package, Brotli or brotlicffi.
- The compatibility rule has exceptions: The maintainers write that they sometimes break their own deprecation rule. Their example is a critical bug that cannot be fixed without a major API change.
- New form-field cap in 3.14.4: `web.Application` now accepts a `client_max_fields` argument, which defaults to 1000. Servers that accept large forms must raise it or set it to 0.
- Two HTTP parsers, recently realigned: aiohttp ships a C parser and a pure-Python parser. Several 3.14.4 fixes bring them into agreement, such as how trailing whitespace in header values and control characters in the request target are handled.

## Numbers (AgentGid data)
- Gid Score: 81.2 (#80 of all tools, 5 of 126 in its category)
- Used in 125 public projects set up for AI coding agents (2.0%)
- Downloads last week: 133,681,616 (as of 2026-11-24), +10.6% over 4 weeks
- GitHub stars: 16,618 (as of 2026-11-24)
- Last push: 2026-11-23

## Often used with
python-dotenv 76.0%, Pydantic 68.0%, Requests 63.2%, Uvicorn 59.2%, FastAPI 57.6%, PyYAML 45.6%

## Checked alternatives (same job)
- httpx: https://agentgid.com/tools/httpx/agent.md
- websocket-client: https://agentgid.com/tools/websocket-client/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/aiohttp/
- Homepage: https://github.com/aio-libs/aiohttp
- Repository: https://github.com/aio-libs/aiohttp
- Source: https://github.com/aio-libs/aiohttp#readme
- Source: https://github.com/aio-libs/aiohttp
- Source: https://github.com/aio-libs/aiohttp/releases
- Source: https://docs.aiohttp.org

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
