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.0a3.tar.gz (822.4 kB view details)

Uploaded Source

Built Distributions

aiohttp-3.4.0a3-cp37-cp37m-win_amd64.whl (575.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

aiohttp-3.4.0a3-cp37-cp37m-win32.whl (549.6 kB view details)

Uploaded CPython 3.7m Windows x86

aiohttp-3.4.0a3-cp37-cp37m-macosx_10_13_x86_64.whl (589.1 kB view details)

Uploaded CPython 3.7m macOS 10.13+ x86-64

aiohttp-3.4.0a3-cp37-cp37m-macosx_10_11_x86_64.whl (597.3 kB view details)

Uploaded CPython 3.7m macOS 10.11+ x86-64

aiohttp-3.4.0a3-cp37-cp37m-macosx_10_10_x86_64.whl (600.8 kB view details)

Uploaded CPython 3.7m macOS 10.10+ x86-64

aiohttp-3.4.0a3-cp36-cp36m-win_amd64.whl (575.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

aiohttp-3.4.0a3-cp36-cp36m-win32.whl (550.1 kB view details)

Uploaded CPython 3.6m Windows x86

aiohttp-3.4.0a3-cp36-cp36m-macosx_10_13_x86_64.whl (592.5 kB view details)

Uploaded CPython 3.6m macOS 10.13+ x86-64

aiohttp-3.4.0a3-cp36-cp36m-macosx_10_11_x86_64.whl (597.4 kB view details)

Uploaded CPython 3.6m macOS 10.11+ x86-64

aiohttp-3.4.0a3-cp36-cp36m-macosx_10_10_x86_64.whl (600.7 kB view details)

Uploaded CPython 3.6m macOS 10.10+ x86-64

aiohttp-3.4.0a3-cp35-cp35m-win_amd64.whl (573.6 kB view details)

Uploaded CPython 3.5m Windows x86-64

aiohttp-3.4.0a3-cp35-cp35m-win32.whl (548.2 kB view details)

Uploaded CPython 3.5m Windows x86

aiohttp-3.4.0a3-cp35-cp35m-macosx_10_13_x86_64.whl (586.5 kB view details)

Uploaded CPython 3.5m macOS 10.13+ x86-64

aiohttp-3.4.0a3-cp35-cp35m-macosx_10_11_x86_64.whl (594.6 kB view details)

Uploaded CPython 3.5m macOS 10.11+ x86-64

aiohttp-3.4.0a3-cp35-cp35m-macosx_10_10_x86_64.whl (598.0 kB view details)

Uploaded CPython 3.5m macOS 10.10+ x86-64

File details

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

File metadata

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

File hashes

Hashes for aiohttp-3.4.0a3.tar.gz
Algorithm Hash digest
SHA256 009e8ee9c435a663ffe8e3409de22d5ee39444dde633043c58747f7412399d9d
MD5 cd4d4c12831d60dabf3ab15c2501a68f
BLAKE2b-256 4cb7a7eb476876cdab0b469fe619fc1e35f9296d7e7f1137f29f772ab26f078a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 575.4 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0a3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c9c210a27767e4f7dc85141a3f7eef105fecc1de099411a3285d0270ca37f2db
MD5 8dc68e423737779dc74d60f2335ac807
BLAKE2b-256 3dd7c921dcf51e81c0927924075b7dc1162e1917acf27a62e2d477f2461af588

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 549.6 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0a3-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 0806af1a897209d19283136cd78933a6bfa23f325a310e0007ffd8fe6a769b7f
MD5 b6fe8c299a2c1f7dca9da730f365b7e8
BLAKE2b-256 25a04fb7ab4e6c36d87291a82e6951e1c123c3a0cf6e5caa24d1e0d67e691091

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp37-cp37m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 589.1 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0a3-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 679c70e02b3eada98402bc2eee29e137f2ef3280812d89c839fe79f516ea581f
MD5 1e8565cce40a0c7824337a9806c4c7ea
BLAKE2b-256 416c1ba23a35d092c190077af3318a89d49083118cb22a669630a17a873d90b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp37-cp37m-macosx_10_11_x86_64.whl
  • Upload date:
  • Size: 597.3 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0a3-cp37-cp37m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 cc845189759ab8d16f6b79457f9e49712567dd3533d63eac51cafd24ab36541b
MD5 5a54c0394afda50900deab764cbd8583
BLAKE2b-256 d761baf7c0b704a11820daba11ebadc9f35ceb91382d9ce244ec1b3b1b17bb2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp37-cp37m-macosx_10_10_x86_64.whl
  • Upload date:
  • Size: 600.8 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for aiohttp-3.4.0a3-cp37-cp37m-macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 a9c119b18b3da7c4ecdcb2486f60677bfc1126591042679c5afd0c4d3088aebe
MD5 1121fd8f71a9778a74089bb0f1fb8a4a
BLAKE2b-256 e649aa5af030cc816afc737c4fc7b3553a19658b664ef25b530efc2d05832976

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 575.5 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

File hashes

Hashes for aiohttp-3.4.0a3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3c17317d75464e32dbbbc48de593ab74047bca8bc9523645a9f6040884f6b87b
MD5 d4e7d8bd5c24c608de2d379775f5bf86
BLAKE2b-256 14b7716ac53ecd2103bdeacb89f4622f5badf6aa86c4155233ba0da314546088

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 550.1 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

File hashes

Hashes for aiohttp-3.4.0a3-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 96f328f8d0d6a38c5ef630f8b3e49e36463c9d9438fb0f89101323b5e1166b8c
MD5 7faced57d40543a2c5c46aa406268706
BLAKE2b-256 2f1f9bfa36f45a7611abf71a3ecade91271ed6bf48a1abeba5fefbf615c0cba6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp36-cp36m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 592.5 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for aiohttp-3.4.0a3-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 33f6d47f973dfc10bbf9524864f85b85255591ec782a60646945baff762934ba
MD5 a9dcff5753d556945edf53e9a980b199
BLAKE2b-256 181ff12ad9d656781e164a06757ea32b9c3d58f0911c239c0c47841326cb06cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp36-cp36m-macosx_10_11_x86_64.whl
  • Upload date:
  • Size: 597.4 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for aiohttp-3.4.0a3-cp36-cp36m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 4c9c6d4e8c8939fa613c32759126218b6e8605dcea86053ff388b36b11597f01
MD5 a4171a4349d3b740a5fbcf66e578ce8f
BLAKE2b-256 55df49a04d4ea5d35425e91b5c113f188e07710e7e99abecd9196d43f37ad859

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp36-cp36m-macosx_10_10_x86_64.whl
  • Upload date:
  • Size: 600.7 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for aiohttp-3.4.0a3-cp36-cp36m-macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 3f5f40446bb627b4b17fd634a48114ae761b93b8c094aa658f281e4634ddf492
MD5 e53692b3ccc0ec648d8be78d5c5b2a02
BLAKE2b-256 5cd80110de6d6e42cd6fef5d4b40411f0030894d4c118ac168ac16f9ae5d89a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 573.6 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0a3-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 582f29242532f0c07f6d59d20e2b0f29d18b909dc136c26b646838f8d8192797
MD5 06266eaf7e2e9054f77097ae70c5c1b4
BLAKE2b-256 9b44ed24948fe9491623bf593a58826f69d633789cc6ac2b70304fb17bf81bff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 548.2 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0a3-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 c00215fb860880c72f731adba3fb10b2603f7c879cf9f602208a6910bd37505d
MD5 e4e8ad12e3736b53d488fc012567488d
BLAKE2b-256 edbdca3ab080868007c0777856ae5139339e97d3b272954707eb0ac4db4c0513

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp35-cp35m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 586.5 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0a3-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 daaa8a6c4755bb227412ad1a1b3ab477f13e8b4813a0de9a5562726b048e350a
MD5 a7730420cda8f63b363ada1b60792226
BLAKE2b-256 0609def4a5b8f55a8129bb0928bf7cd7673d8d924e8332f359c71de500e4f50e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp35-cp35m-macosx_10_11_x86_64.whl
  • Upload date:
  • Size: 594.6 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0a3-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 8f8341c1cbe4b6753161224891d39ffc9058af8e51f298f389ac2b06f06bf84f
MD5 d229e4e5bc2828234fc291301677c986
BLAKE2b-256 94af9629a98b8d591394739e82abe507fceb9dc08d5e80e3eff3805198b499a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aiohttp-3.4.0a3-cp35-cp35m-macosx_10_10_x86_64.whl
  • Upload date:
  • Size: 598.0 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.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3

File hashes

Hashes for aiohttp-3.4.0a3-cp35-cp35m-macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 3ecdc77c5d622d2d33cbc05ceed37004bbfe0d9504e018762841587225ceddf3
MD5 f46562eec492a69877e9bfb840cccde1
BLAKE2b-256 cd0f6475167b34d34a79237d991db4340c6f79106d373ff3b0f6e8f893c2e9a6

See more details on using hashes here.

Supported by

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