Skip to main content

Async http client/server framework (asyncio)

Project description

Async http client/server framework

aiohttp logo

Travis status for master branch AppVeyor status for master branch codecov.io 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 without the Callback Hell.

  • Web-server has middlewares and pluggable routing.

Getting started

Client

To retrieve 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, 'http://python.org')
        print(html)

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

Server

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 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(msg.data))
        elif msg.type == web.WSMsgType.binary:
            await ws.send_bytes(msg.data)
        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)])

web.run_app(app)

Documentation

https://aiohttp.readthedocs.io/

Demos

https://github.com/aio-libs/aiohttp-demos

Communication channels

aio-libs google group: https://groups.google.com/forum/#!forum/aio-libs

Feel free to post your questions and ideas here.

gitter chat https://gitter.im/aio-libs/Lobby

We support Stack Overflow. Please add aiohttp tag to your question there.

Requirements

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

License

aiohttp is offered under the Apache 2 license.

Keepsafe

The aiohttp community would like to thank Keepsafe (https://www.getkeepsafe.com) for it’s support in the early days of the project.

Source code

The latest developer version is available in a github repository: https://github.com/aio-libs/aiohttp

Benchmarks

If you are interested in by efficiency, AsyncIO community maintains a list of benchmarks on the official wiki: https://github.com/python/asyncio/wiki/Benchmarks

Changelog

3.3.2 (2018-06-12)

  • Many HTTP proxies has buggy keepalive support. Let’s not reuse connection but close it after processing every response. (#3070)

  • Provide vendor source files in tarball (#3076)

3.3.1 (2018-06-05)

  • Fix sock_read timeout. (#3053)

  • When using a server-request body as the data= argument of a client request, iterate over the content with readany instead of readline to avoid Line too long errors. (#3054)

3.3.0 (2018-06-01)

Features

  • Raise ConnectionResetError instead of CancelledError on trying to write to a closed stream. (#2499)

  • Implement ClientTimeout class and support socket read timeout. (#2768)

  • Enable logging when aiohttp.web is used as a program (#2956)

  • Add canonical property to resources (#2968)

  • Forbid reading response BODY after release (#2983)

  • Implement base protocol class to avoid a dependency from internal asyncio.streams.FlowControlMixin (#2986)

  • Cythonize @helpers.reify, 5% boost on macro benchmark (#2995)

  • Optimize HTTP parser (#3015)

  • Implement runner.addresses property. (#3036)

  • Use bytearray instead of a list of bytes in websocket reader. It improves websocket message reading a little. (#3039)

  • Remove heartbeat on closing connection on keepalive timeout. The used hack violates HTTP protocol. (#3041)

  • Limit websocket message size on reading to 4 MB by default. (#3045)

Bugfixes

  • Don’t reuse a connection with the same URL but different proxy/TLS settings (#2981)

  • When parsing the Forwarded header, the optional port number is now preserved. (#3009)

Improved Documentation

  • Make Change Log more visible in docs (#3029)

  • Make style and grammar improvements on the FAQ page. (#3030)

  • Document that signal handlers should be async functions since aiohttp 3.0 (#3032)

Deprecations and Removals

  • Deprecate custom application’s router. (#3021)

Misc

  • #3008, #3011

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp-3.4.0b1.tar.gz (822.6 kB view details)

Uploaded Source

Built Distributions

aiohttp-3.4.0b1-cp37-cp37m-win_amd64.whl (576.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

aiohttp-3.4.0b1-cp37-cp37m-win32.whl (550.1 kB view details)

Uploaded CPython 3.7m Windows x86

aiohttp-3.4.0b1-cp37-cp37m-macosx_10_13_x86_64.whl (590.0 kB view details)

Uploaded CPython 3.7m macOS 10.13+ x86-64

aiohttp-3.4.0b1-cp37-cp37m-macosx_10_11_x86_64.whl (598.5 kB view details)

Uploaded CPython 3.7m macOS 10.11+ x86-64

aiohttp-3.4.0b1-cp37-cp37m-macosx_10_10_x86_64.whl (602.0 kB view details)

Uploaded CPython 3.7m macOS 10.10+ x86-64

aiohttp-3.4.0b1-cp36-cp36m-win_amd64.whl (576.3 kB view details)

Uploaded CPython 3.6m Windows x86-64

aiohttp-3.4.0b1-cp36-cp36m-win32.whl (550.5 kB view details)

Uploaded CPython 3.6m Windows x86

aiohttp-3.4.0b1-cp36-cp36m-macosx_10_13_x86_64.whl (593.4 kB view details)

Uploaded CPython 3.6m macOS 10.13+ x86-64

aiohttp-3.4.0b1-cp36-cp36m-macosx_10_11_x86_64.whl (598.6 kB view details)

Uploaded CPython 3.6m macOS 10.11+ x86-64

aiohttp-3.4.0b1-cp36-cp36m-macosx_10_10_x86_64.whl (601.9 kB view details)

Uploaded CPython 3.6m macOS 10.10+ x86-64

aiohttp-3.4.0b1-cp35-cp35m-win_amd64.whl (574.4 kB view details)

Uploaded CPython 3.5m Windows x86-64

aiohttp-3.4.0b1-cp35-cp35m-win32.whl (548.7 kB view details)

Uploaded CPython 3.5m Windows x86

aiohttp-3.4.0b1-cp35-cp35m-macosx_10_13_x86_64.whl (587.4 kB view details)

Uploaded CPython 3.5m macOS 10.13+ x86-64

aiohttp-3.4.0b1-cp35-cp35m-macosx_10_11_x86_64.whl (595.8 kB view details)

Uploaded CPython 3.5m macOS 10.11+ x86-64

aiohttp-3.4.0b1-cp35-cp35m-macosx_10_10_x86_64.whl (599.2 kB view details)

Uploaded CPython 3.5m macOS 10.10+ x86-64

File details

Details for the file aiohttp-3.4.0b1.tar.gz.

File metadata

  • Download URL: aiohttp-3.4.0b1.tar.gz
  • Upload date:
  • Size: 822.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0b1.tar.gz
Algorithm Hash digest
SHA256 faab0f953ae1b029bf29fbff34ea6f61d5077a23bc3ae7f05fd8d8582e363437
MD5 3fe4c6fc51f9b2368221fb42b00d18a0
BLAKE2b-256 61348ee431470878b78011f6771101039bce6b99ee887cea24792327b3fcc65b

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 576.3 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0b1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4899330690961f690d90c5ebbcc3ed9a8569615a23f6dc593e3a32deb5dec7b5
MD5 ccb48d04c4320e1697b6ccbeee371afe
BLAKE2b-256 5bceebc5c973b88663cefc7898092ebdb241f023628200ad3eccedc62db48a6c

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp37-cp37m-win32.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 550.1 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0b1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 3a3c805cf4bb55299053207272471ff0d963df9c51a69a3d2299ac16c47fae5a
MD5 e6f158df626a1be7c97d64c9e6d0e0eb
BLAKE2b-256 c36fb2a6914be81d9fff714138768317e86a0fba1e69fc9b1b7fca84c8ea5286

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp37-cp37m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp37-cp37m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 590.0 kB
  • Tags: CPython 3.7m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0b1-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5077e3c15e41f928e3dd850b8f3ec67e6e0a13e2dd5dd8bc2a30ac7571036e24
MD5 f28b5c6bfd8325284a21d4f861910d34
BLAKE2b-256 808d202a77583d9bf61bec1e24d73581ce07d095d0b6ead1824a6dc6ea247b82

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp37-cp37m-macosx_10_11_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp37-cp37m-macosx_10_11_x86_64.whl
  • Upload date:
  • Size: 598.5 kB
  • Tags: CPython 3.7m, macOS 10.11+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0b1-cp37-cp37m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 e5d4d313ebd2d4b4e916d5ced35c0dc4de9155d6a2f36faf5098379a7a7a37be
MD5 00551d49ccdaf2d005cf28cddaeb4157
BLAKE2b-256 88190b34894a30784a38336040da2b63524dd2f8d1d31b999d6d2cdb66edb236

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp37-cp37m-macosx_10_10_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp37-cp37m-macosx_10_10_x86_64.whl
  • Upload date:
  • Size: 602.0 kB
  • Tags: CPython 3.7m, macOS 10.10+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0b1-cp37-cp37m-macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 aaa521a80d09f9aa3031bb11b70818e46ecb0bf994fd9ac4634f6300b91903d4
MD5 34bd9f40cbdc9c9d04c05053008c6dfb
BLAKE2b-256 b5ed9a877cee416854851ffec2a02fc6eae352a1ba7b1fd425228606e3c524f6

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 576.3 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

File hashes

Hashes for aiohttp-3.4.0b1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 bf2b475a16494abc21d44a7a7dba428d25ea8a6e69d0772466870280729a0c4a
MD5 70575bd9261ffe7b8d2e582b4e67bae1
BLAKE2b-256 0267cc7b07a70cd67da14d7aeb91606da4e0cbf9a87c484549542a3a1c30270a

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp36-cp36m-win32.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 550.5 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

File hashes

Hashes for aiohttp-3.4.0b1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 c03d5b111ad3d18254680015f5cf885efb43bd5984678d8b6ece3f9dbb38c248
MD5 f18d0cc6e04e6457fb8c8bfb83bc5092
BLAKE2b-256 832ff23026727433e06ba1f88e5f8cb60d125b45100e7db25f75c3fa80c89f79

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp36-cp36m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp36-cp36m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 593.4 kB
  • Tags: CPython 3.6m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for aiohttp-3.4.0b1-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 82f0dd3affe053bb89fcdb24120f72bf284d1d9f1bf2d169e0cf98321855d676
MD5 07cbdbf1d7b9635b886fc9f96ced096c
BLAKE2b-256 2c95a60ed6b65decd2ca0a057dc73e7aa34c2592f3306bcd3fb608342fd862a6

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp36-cp36m-macosx_10_11_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp36-cp36m-macosx_10_11_x86_64.whl
  • Upload date:
  • Size: 598.6 kB
  • Tags: CPython 3.6m, macOS 10.11+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for aiohttp-3.4.0b1-cp36-cp36m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 96119c9fc5ed7fbccfb28496c00357f14d052b73e75a621f31e93a85350c89a8
MD5 2327abda7744dedeee78d47667e16772
BLAKE2b-256 54784a369d147f5013246f35b0385a4f2c49bfcbe3a1c3dc2148b9067646baf5

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp36-cp36m-macosx_10_10_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp36-cp36m-macosx_10_10_x86_64.whl
  • Upload date:
  • Size: 601.9 kB
  • Tags: CPython 3.6m, macOS 10.10+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for aiohttp-3.4.0b1-cp36-cp36m-macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 bb80821965e99e437ae001cd68d4b962a8043edc6c3c27dd330f489b1087813b
MD5 6e5624ee9d7f7f1f4a6c7ab7c3cb12ab
BLAKE2b-256 ece6c5d97865378f6318f2b6bf4f9d0c238ea5a9015d8da2cbf16d9039e20ae5

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 574.4 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0b1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 0f697b952490d5bb57eea230e9c4f526232b5c90dac65f17b5586674ffca33de
MD5 039457049b7b078cde38e65df4cd15b6
BLAKE2b-256 e42be4408b7161f41c324056653374a51731a8de794ec933b8bcba6005c9d7a3

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp35-cp35m-win32.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 548.7 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0b1-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 9d1334c35af34a8bb9319acf387f5fa4ae5913106f7e732548ceb1f0f085b590
MD5 d9ce278d50aad1a8d54c058d1e2aae00
BLAKE2b-256 a7dca6084c881bc58ee04f05cafedc740c45536fbaa1eb4a032b2be20a69e6b8

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp35-cp35m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp35-cp35m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 587.4 kB
  • Tags: CPython 3.5m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0b1-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d34111c32069ec2ee7f97826f7d4865c80a52821594961701f45004392e03b61
MD5 8beaccd988450cfd2c926d0d63eed3b1
BLAKE2b-256 ae0d7e2eaed304557d595c02c1ee4533d22bb3bcbfe280d732cbad6b5e61dd2a

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp35-cp35m-macosx_10_11_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp35-cp35m-macosx_10_11_x86_64.whl
  • Upload date:
  • Size: 595.8 kB
  • Tags: CPython 3.5m, macOS 10.11+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0b1-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 79a71afddd9fce3c70fcaf3e6bce27b865821a59506bc1ef9c08f70ddcf62b1b
MD5 0cccc2d11f01bc65efacf20b3a30baf5
BLAKE2b-256 fded0db12b5b2edb1e155322816558fa08ae6655bcf8c5758a24e5af8939169b

See more details on using hashes here.

File details

Details for the file aiohttp-3.4.0b1-cp35-cp35m-macosx_10_10_x86_64.whl.

File metadata

  • Download URL: aiohttp-3.4.0b1-cp35-cp35m-macosx_10_10_x86_64.whl
  • Upload date:
  • Size: 599.2 kB
  • Tags: CPython 3.5m, macOS 10.10+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0b1-cp35-cp35m-macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 67250f5d5221a518607e6f19327d6dd86108dafd95503143a4af0bafcc84c708
MD5 29561097ef1411c361f1880e386f2937
BLAKE2b-256 6027f03783e6a6ab135a17f8f7ef95c51e0f70c975a0058271c51e31d211564f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page