skip to navigation
skip to content

Not Logged In

aiohttp 0.17.4

http client/server for asyncio

http client/server for asyncio


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



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:

Getting started


To retrieve something from the web:

import aiohttp
import asyncio

def get_body(url):
    response = yield from aiohttp.request('GET', url)
    return (yield from

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

You can use the get command like this anywhere in your asyncio powered program:

response = yield from aiohttp.request('GET', '')
body = yield from

If you want to use timeouts for aiohttp client side please use standard asyncio approach:

yield from asyncio.wait_for(request('GET', url), 10)


This is simple usage example:

import asyncio
from aiohttp import web

def handle(request):
    name = request.match_info.get('name', "Anonymous")
    text = "Hello, " + name
    return web.Response(body=text.encode('utf-8'))

def wshandler(request):
    ws = web.WebSocketResponse()

    while True:
        msg = yield from ws.receive()

        if == web.MsgType.text:
            ws.send_str("Hello, {}".format(
        elif == web.MsgType.binary:
        elif == web.MsgType.close:

    return ws

def init(loop):
    app = web.Application(loop=loop)
    app.router.add_route('GET', '/echo', wshandler)
    app.router.add_route('GET', '/{name}', handle)

    srv = yield from loop.create_server(app.make_handler(),
                                        '', 8080)
    print("Server started at")
    return srv

loop = asyncio.get_event_loop()


0.17.4 (09-29-2015)

  • Properly parse URL path in aiohttp.web.Request #489
  • Add missing coroutine decorator, the client api is await-compatible now

0.17.3 (08-28-2015)

  • Remove Content-Length header on compressed responses #450
  • Support Python 3.5
  • Improve performance of transport in-use list #472
  • Fix connection pooling #473

0.17.2 (08-11-2015)

  • Don’t forget to pass data argument forward #462
  • Fix multipart read bytes count #463

0.17.1 (08-10-2015)

  • Fix multidict comparsion to arbitrary abc.Mapping

0.17.0 (08-04-2015)

  • Make StaticRoute support Last-Modified and If-Modified-Since headers #386
  • Add Request.if_modified_since and Stream.Response.last_modified properties
  • Fix deflate compression when writing a chunked response #395
  • Request`s content-length header is cleared now after redirect from POST method #391
  • Return a 400 if server received a non HTTP content #405
  • Fix keep-alive support for aiohttp clients #406
  • Allow gzip compression in high-level server response interface #403
  • Rename TCPConnector.resolve and family to dns_cache #415
  • Make UrlDispatcher ignore quoted characters during url matching #414 Backward-compatibility warning: this may change the url matched by your queries if they send quoted character (like %2F for /) #414
  • Use optional cchardet accelerator if present #418
  • Borrow loop from Connector in ClientSession if loop is not set
  • Add context manager support to ClientSession for session closing.
  • Add toplevel get(), post(), put(), head(), delete(), options(), patch() coroutines.
  • Fix IPv6 support for client API #425
  • Pass SSL context through proxy connector #421
  • Make the rule: path for add_route should start with slash
  • Don’t process request finishing by low-level server on closed event loop
  • Don’t override data if multiple files are uploaded with same key #433
  • Ensure multipart.BodyPartReader.read_chunk read all the necessary data to avoid false assertions about malformed multipart payload
  • Dont sent body for 204, 205 and 304 http exceptions #442
  • Correctly skip Cython compilation in MSVC not found #453
  • Add response factory to StaticRoute #456
  • Don’t append trailing CRLF for multipart.BodyPartReader #454
File Type Py Version Uploaded on Size
aiohttp-0.17.4.tar.gz (md5) Source 2015-09-29 463KB
  • Downloads (All Versions):
  • 912 downloads in the last day
  • 6977 downloads in the last week
  • 30652 downloads in the last month