{"id":202,"library":"aiohttp","title":"aiohttp","description":"Async HTTP client/server framework for asyncio. Provides both a client (ClientSession) and a web server (web.Application). Current version is 3.13.3 (Jan 2026). Has removed several long-deprecated parameters that LLMs still generate.","status":"active","version":"3.13.3","language":"python","source_language":"en","source_url":"https://docs.aiohttp.org/en/stable/changes.html","tags":["http","async","client","server","asyncio","websockets"],"install":[{"cmd":"pip install aiohttp","lang":"bash","label":"Core"},{"cmd":"pip install aiohttp[speedups]","lang":"bash","label":"With Cython speedups (aiodns, brotli, backports.zstd)"}],"dependencies":[{"reason":"Faster DNS resolution. Included in aiohttp[speedups]. Highly recommended.","package":"aiodns","optional":true},{"reason":"Brotli decompression support. Included in aiohttp[speedups].","package":"brotli","optional":true}],"imports":[{"note":"ClientSession must be used as an async context manager or closed explicitly with await session.close(). Creating it outside an async context was removed.","wrong":"session = aiohttp.ClientSession()\nresp = await session.get('https://example.com')\n# session never closed — connector leak","symbol":"ClientSession","correct":"import aiohttp\n\nasync with aiohttp.ClientSession() as session:\n    async with session.get('https://example.com') as resp:\n        data = await resp.json()"},{"note":"The timeout parameter must be an aiohttp.ClientTimeout instance, not a plain int or float. Passing an int silently fails at request time with an AttributeError.","wrong":"async with aiohttp.ClientSession(timeout=30) as session: ...\n# raises AttributeError: 'int' object has no attribute 'total'","symbol":"ClientTimeout","correct":"timeout = aiohttp.ClientTimeout(total=30)\nasync with aiohttp.ClientSession(timeout=timeout) as session: ..."}],"quickstart":{"code":"import aiohttp\nimport asyncio\n\nasync def main():\n    timeout = aiohttp.ClientTimeout(total=30)\n    async with aiohttp.ClientSession(timeout=timeout) as session:\n        async with session.get('https://httpbin.org/get') as resp:\n            print(resp.status)\n            data = await resp.json()\n            print(data)\n\nasyncio.run(main())\n\n# Server\nfrom aiohttp import web\n\nasync def handle(request):\n    return web.Response(text='Hello')\n\napp = web.Application()\napp.add_routes([web.get('/', handle)])\nweb.run_app(app)","lang":"python","description":"Client with ClientTimeout and basic web server setup."},"warnings":[{"fix":"timeout = aiohttp.ClientTimeout(total=30, connect=10)\nasync with aiohttp.ClientSession(timeout=timeout) as session: ...","message":"timeout= parameter must be aiohttp.ClientTimeout, not int/float. Passing timeout=30 raises AttributeError: 'int' object has no attribute 'total' at request time, not at session creation. The error is confusing and delayed.","severity":"breaking","affected_versions":">= 3.9"},{"fix":"Remove all loop= arguments. aiohttp uses the running event loop automatically.","message":"loop= parameter removed from ClientSession, TCPConnector, and all other aiohttp objects. Was deprecated for years; removed in 3.9. LLM-generated code from older tutorials passes loop=asyncio.get_event_loop().","severity":"breaking","affected_versions":">= 3.9"},{"fix":"Use aiohttp.ClientTimeout(total=..., connect=..., sock_read=...) instead.","message":"read_timeout and conn_timeout constructor parameters removed from ClientSession. Replaced by ClientTimeout.","severity":"breaking","affected_versions":">= 3.9"},{"fix":"Use ssl=False to skip verification, ssl=ssl_context for custom context, ssl=aiohttp.Fingerprint(...) for fingerprint pinning.","message":"verify_ssl=, ssl_context=, and fingerprint= parameters deprecated in request methods. Replaced by unified ssl= parameter.","severity":"breaking","affected_versions":">= 3.9"},{"fix":"Use asyncio.get_event_loop() or asyncio.get_running_loop() directly.","message":"app.loop, request.loop, client.loop, connector.loop properties deprecated and scheduled for removal in aiohttp 4.0.","severity":"deprecated","affected_versions":">= 3.9"},{"fix":"Always create ClientSession inside an async function or use async with at the point of use.","message":"Creating ClientSession outside of an async context (e.g. at module level or in __init__) raises DeprecationWarning and will raise RuntimeError in a future version.","severity":"gotcha","affected_versions":"all"},{"fix":"Always consume the response body inside the async with session.get(...) as resp: block.","message":"Response body must be consumed before the response context manager exits, or the connection is left in a broken state. await resp.json() / await resp.text() / await resp.read() must be called inside the async with block.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-12T10:07:47.426Z","next_check":"2026-06-25T00:00:00.000Z","problems":[{"fix":"Install the module using pip: 'pip install aiohttp'.","cause":"The 'aiohttp' module is not installed in the Python environment.","error":"ModuleNotFoundError: No module named 'aiohttp'"},{"fix":"Rename the script to avoid naming conflicts, e.g., 'my_script.py'.","cause":"The script is named 'aiohttp.py', causing a conflict with the aiohttp module.","error":"AttributeError: module 'aiohttp' has no attribute 'ClientSession'"},{"fix":"Rename the script to a different name, such as 'my_script.py'.","cause":"The script is named 'aiohttp.py', leading to a circular import issue.","error":"AttributeError: partially initialized module 'aiohttp' has no attribute 'ClientSession' (most likely due to a circular import)"},{"fix":"Remove the `loop` argument from the `ClientSession` constructor. `aiohttp` will automatically use the currently running event loop. For example, change `aiohttp.ClientSession(loop=my_loop)` to `aiohttp.ClientSession()`.","cause":"The 'loop' argument for `aiohttp.ClientSession` (and many `asyncio` primitives) was deprecated in `aiohttp` versions 2.x and removed in Python 3.10+ as event loops are now implicitly managed by `asyncio.run()` or `asyncio.get_running_loop()`. LLMs often generate code using this outdated parameter.","error":"TypeError: ClientSession.__init__() got an unexpected keyword argument 'loop'"},{"fix":"Instantiate `aiohttp.ClientSession()` and use its methods for HTTP requests. For example, change `await aiohttp.get(url)` to `async with aiohttp.ClientSession() as session: await session.get(url)`.","cause":"Direct top-level `aiohttp.get()` (or `post`, `put`, etc.) methods were removed in older `aiohttp` versions. Modern `aiohttp` client usage requires creating a `ClientSession` instance first.","error":"AttributeError: module 'aiohttp' has no attribute 'get'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.44,"mem_mb":14.3,"disk_size":"27.1M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.52,"mem_mb":14.3,"disk_size":"34.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.32,"mem_mb":14.3,"disk_size":"29M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.36,"mem_mb":14.3,"disk_size":"38M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.64,"mem_mb":15.3,"disk_size":"29.6M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.73,"mem_mb":15.3,"disk_size":"37.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.51,"mem_mb":15.3,"disk_size":"32M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.59,"mem_mb":15.3,"disk_size":"41M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.77,"mem_mb":15.5,"disk_size":"21.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.86,"mem_mb":15.5,"disk_size":"29.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.7,"mem_mb":15.5,"disk_size":"24M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.8,"mem_mb":15.5,"disk_size":"33M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.8,"mem_mb":15.7,"disk_size":"20.9M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.86,"mem_mb":15.7,"disk_size":"29.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.72,"mem_mb":15.7,"disk_size":"23M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.78,"mem_mb":15.7,"disk_size":"32M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.41,"mem_mb":13.8,"disk_size":"27.3M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.41,"mem_mb":13.8,"disk_size":"36.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.37,"mem_mb":13.8,"disk_size":"30M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"speedups","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.41,"mem_mb":13.8,"disk_size":"41M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":-1},{"runtime":"python:3.10-slim","exit_code":-1},{"runtime":"python:3.11-alpine","exit_code":-1},{"runtime":"python:3.11-slim","exit_code":-1},{"runtime":"python:3.12-alpine","exit_code":-1},{"runtime":"python:3.12-slim","exit_code":-1},{"runtime":"python:3.13-alpine","exit_code":-1},{"runtime":"python:3.13-slim","exit_code":-1},{"runtime":"python:3.9-alpine","exit_code":-1},{"runtime":"python:3.9-slim","exit_code":-1}]}}