Asynchronous HTTP client/server framework for asyncio and Python

License: Apache-2.0

Language: Python

Keywords: aiohttp, async, asyncio, http, http-client, http-server, python

Async http client/server framework

aiohttp logo

Travis status for master branch AppVeyor status for master branch status for master branch Latest PyPI package version Latest Read The Docs 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 pluggable routing.

Getting started


To get something from the web:

import aiohttp
import asyncio

async def fetch(session, url):
    async with session.get(url) as response:
        return await response.text()

async def main():
    async with aiohttp.ClientSession() as session:
        html = await fetch(session, '')

if __name__ == '__main__':
    loop = asyncio.get_event_loop()


An example using a simple server:

# 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)])




External links

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

Communication channels

aio-libs google group:!forum/aio-libs

Feel free to post your questions and ideas here.

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


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:

Project Statistics

Sourcerank 19
Repository Size 14.6 MB
Stars 8,117
Forks 1,207
Watchers 254
Open issues 261
Dependencies 46
Contributors 423
Tags 191
Last updated
Last pushed

Top Contributors See all

Andrew Svetlov Nikolay Kim bot Sviatoslav Sydorenko Alexander Shorin Alexey Popravka Jashandeep Sohi Anton Kasyanov Samuel Colvin Pau Freixes Nikolay Novik Arthur Darcet Vladimir Rutsky redixin Andrew Leech Коренберг Марк Manuel Miranda Alexander Dutton Louis-Philippe Huberdeau Theron Luhn

Packages Referencing this Repo

Async http client/server framework (asyncio)
Latest release 3.6.0a0 - Updated - 8.12K stars

Recent Tags See all

v3.5.4 January 12, 2019
v3.5.3 January 10, 2019
v4.0.0a0 January 09, 2019
v3.5.2 January 08, 2019
v3.5.1 December 24, 2018
v3.5.0 December 22, 2018
v3.5.0b3 December 22, 2018
v3.5.0b2 December 21, 2018
v3.5.0b1 December 20, 2018
v3.5.0a1 November 20, 2018
v3.4.4 September 05, 2018
v3.4.3 September 04, 2018
v3.4.2 September 01, 2018
v3.4.1 August 28, 2018
v3.4.0 August 25, 2018

Interesting Forks See all

http client/server for asyncio (PEP-3156)
Python - Apache-2.0 - Last pushed - 1 stars
Async http client/server framework (asyncio)
Python - Last pushed - 1 stars
Async http client/server framework (asyncio)
Python - Last pushed - 1 stars
Async http client/server framework (asyncio)
Python - Updated - 1 stars
Async http client/server framework (asyncio)
Python - Updated - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2019-01-31 16:15:23 UTC

Login to resync this repository