Key Features

Asynchronous HTTP client/server framework for asyncio and Python
Under Other
By aio-libs

python hacktoberfest http async asyncio http-client http-server aiohttp

Async http client/server framework

.. image::
:height: 64px
:width: 64px
:alt: aiohttp logo


.. image::
:alt: GitHub Actions status for master branch

.. image::
:alt: status for master branch

.. image::
:alt: Latest PyPI package version

.. image::
:alt: Downloads count

.. image::
:alt: Latest Read The Docs

.. image::
:alt: Discourse status

.. image::
:alt: Chat on Gitter

Key Features

Getting started

To get something from the web:

.. code-block:: python

import aiohttp
import asyncio

async def main():

  async with aiohttp.ClientSession() as session:
async with session.get('') as response:

print("Status:", response.status)
print("Content-type:", response.headers['content-type'])

html = await response.text()
print("Body:", html[:15], "...")

loop = asyncio.get_event_loop()

This prints:

.. code-block::

Status: 200
Content-type: text/html; charset=utf-8
Body: <!doctype html> ...

Coming from requests <> ? Read why we need so many lines <>.


An example using a simple server:

.. code-block:: python

# examples/
from aiohttp import web

async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(text=text)

async def wshandle(request):
ws = web.WebSocketResponse()
await ws.prepare(request)

async for msg in ws:
if msg.type == web.WSMsgType.text:
await ws.send_str("Hello, {}".format(
elif msg.type == web.WSMsgType.binary:
await ws.send_bytes(
elif msg.type == web.WSMsgType.close:

return ws

app = web.Application()
app.add_routes([web.get('/', handle),
web.get('/echo', wshandle),
web.get('/{name}', handle)])

if __name__ == '__main__':



External links

Feel free to make a Pull Request for adding your link to these pages!

Communication channels

aio-libs discourse group:

gitter chat

We support Stack Overflow
Please add aiohttp tag to your question there.


Optionally you may install the cChardet_ and aiodns_ libraries (highly
recommended for sake of speed).

.. _chardet:
.. _aiodns:
.. _multidict:
.. _yarl:
.. _async-timeout:
.. _cChardet:


aiohttp is offered under the Apache 2 license.


The aiohttp community would like to thank Keepsafe
( for its support in the early days of
the project.

Source code

The latest developer version is available in a GitHub repository:


If you are interested in efficiency, the AsyncIO community maintains a
list of benchmarks on the official wiki: