Github url


by aio-libs

aio-libs /aiohttp

Asynchronous HTTP client/server framework for asyncio and Python

9.9K Stars 1.4K Forks Last release: 9 months ago (v3.6.2) Apache License 2.0 6.9K Commits 213 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Async http client/server framework

.. image::\_static/aiohttp-icon-128x128.png :height: 64px :width: 64px :alt: aiohttp logo


.. image:: :target: :align: right :alt: Azure Pipelines status for master branch

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

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

.. 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: ...

Comming from

requests <https:></https:>

_ ? Read

why we need so many lines <https:></https:>



An example using a simple server:

.. code-block:: python

# examples/server\ 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: break return ws app = web.Application() app.add\_routes([web.get('/', handle), web.get('/echo', wshandle), web.get('/{name}', handle)]) if \_\_name\_\_ == '\_\_main\_\_':\_app(app)



External links

  • Third party libraries<http:></http:>
  • Built with aiohttp<http:></http:>
  • Powered by aiohttp<http:></http:>

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<https:></https:>

_. Please add aiohttp tag to your question there.


  • Python >= 3.5.3
  • 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:



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:

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.