Awesome Open Source
Awesome Open Source

================================== Async http client/server framework

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


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

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

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

.. image:: :target: :alt: Downloads count

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

.. image:: :target: :alt: Discourse status

.. image:: :target: :alt: Chat on Gitter

Key Features

  • Supports both client and server side of HTTP protocol.
  • Supports both client and server Web-Sockets out-of-the-box and avoids Callback Hell.
  • Provides Web-server with middlewares and plugable routing.

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() loop.run_until_complete(main())

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

  • Third party libraries <>_
  • Built with aiohttp <>_
  • Powered by aiohttp <>_

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.


  • Python >= 3.7
  • async-timeout_
  • attrs_
  • chardet_
  • multidict_
  • yarl_

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

.. _chardet: .. _aiodns: .. _attrs: .. _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:

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (54,447
http (929
async (492
asyncio (280
http-server (197
http-client (185
aiohttp (71