Python HTML Makefile Shell Batchfile PLpgSQL
Failed to load latest commit information.
aiohttp cleanup deprecation warnings and docs Feb 19, 2017
benchmark Update twisted from 16.6.0 to 17.1.0 Feb 11, 2017
demos Fix wrong string formatting. Feb 10, 2017
docs cleanup deprecation warnings and docs Feb 19, 2017
examples Fix examples Dec 16, 2016
tests cleanup deprecation warnings and docs Feb 19, 2017
vendor/http-parser initial implementation Feb 15, 2017
.coveragerc Improve test coverage Jan 14, 2015
.gitignore rename _parser Feb 18, 2017
.travis.yml Awaiting on WebSocketResponse.send_* does not work #1645 Feb 16, 2017
CHANGES.rst refactor low-level api Feb 18, 2017
CONTRIBUTING.rst fix spelling Jan 21, 2017
CONTRIBUTORS.txt Update CONTRIBUTORS.txt Feb 18, 2017
DEPRECATIONS.rst drop wsgi #1108 Feb 16, 2017
HISTORY.rst back to development Feb 8, 2017 some corrections and clarifications in the issue/pr templates. (#911) Jun 4, 2016
LICENSE.txt Update LICENSE's years Jan 3, 2016 fix CHANGES.{txt,rst} Aug 12, 2016
Makefile fix CONNECT support in _parser Feb 16, 2017 Fixed PR template (#1328) Oct 23, 2016
README.rst Awaiting on WebSocketResponse.send_* does not work #1645 Feb 16, 2017
appveyor.yml pin new yarl version, add more tests for quoting Feb 16, 2017 build py3.6 wheels Feb 9, 2017
build.cmd Try to fix 64 build on Windows Jan 8, 2016
codecov.yml Shrink codecov range Aug 27, 2016
requirements-ci.txt pin new yarl version, add more tests for quoting Feb 16, 2017
requirements-dev.txt Update ipython from 5.2.1 to 5.2.2 Feb 3, 2017
requirements-wheel.txt Update pytest from 3.0.5 to 3.0.6 Jan 22, 2017 Update wheel building instructions Jul 14, 2016
setup.cfg Merge branch 'master' into issue-355/normalize_path_middleware Jan 22, 2017 rename _parser Feb 18, 2017
tox.ini Add pyflakes version requirements Oct 6, 2015


http client/server for asyncio

aiohttp logo


  • Supports both client and server side of HTTP protocol.
  • Supports both client and server Web-Sockets out-of-the-box.
  • Web-server has middlewares and pluggable routing.

Getting started


To retrieve something from the web:

import aiohttp
import asyncio

async def fetch(session, url):
    with aiohttp.Timeout(10, loop=session.loop):
        async with session.get(url) as response:
            return await response.text()

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

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


This is simple usage example:

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 wshandler(request):
    ws = web.WebSocketResponse()
    await ws.prepare(request)

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

    return ws

app = web.Application()
app.router.add_get('/echo', wshandler)
app.router.add_get('/', handle)
app.router.add_get('/{name}', handle)


Note: examples are written for Python 3.5+ and utilize PEP-492 aka async/await. If you are using Python 3.4 please replace await with yield from and async def with @coroutine e.g.:

async def coro(...):
    ret = await f()

should be replaced by:

def coro(...):
    ret = yield from f()


Discussion list

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


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


aiohttp is offered under the Apache 2 license.

Source code

The latest developer version is available in a github repository:


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