Skip to main content

Async http client/server framework

aiohttp logo

Travis 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.2.0 (2018-05-06)

Features

  • Raise TooManyRedirects exception when client gets redirected too many times instead of returning last response. (#2631)

  • Extract route definitions into separate web_routedef.py file (#2876)

  • Raise an exception on request body reading after sending response. (#2895)

  • ClientResponse and RequestInfo now have real_url property, which is request url without fragment part being stripped (#2925)

  • Speed up connector limiting (#2937)

  • Added and links property for ClientResponse object (#2948)

  • Add request.config_dict for exposing nested applications data. (#2949)

  • Speed up HTTP headers serialization, server micro-benchmark runs 5% faster now. (#2957)

  • Apply assertions in debug mode only (#2966)

Bugfixes

  • expose property app for TestClient (#2891)

  • Call on_chunk_sent when write_eof takes as a param the last chunk (#2909)

  • A closing bracket was added to __repr__ of resources (#2935)

  • Fix compression of FileResponse (#2942)

  • Fixes some bugs in the limit connection feature (#2964)

Improved Documentation

  • Drop async_timeout usage from documentation for client API in favor of timeout parameter. (#2865)

  • Improve Gunicorn logging documentation (#2921)

  • Replace multipart writer .serialize() method with .write() in documentation. (#2965)

Deprecations and Removals

  • Deprecate Application.make_handler() (#2938)

Misc

  • #2958

Release files for aiohttp 3.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp 3.2.0
File Size Uploaded
aiohttp-3.2.0.tar.gz 719.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for aiohttp 3.2.0
File
aiohttp-3.2.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
aiohttp-3.2.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
aiohttp-3.2.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
aiohttp-3.2.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
aiohttp-3.2.0-cp36-cp36m-macosx_10_12_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.12+ x86-64 Details
aiohttp-3.2.0-cp36-cp36m-macosx_10_11_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.11+ x86-64 Details
aiohttp-3.2.0-cp36-cp36m-macosx_10_10_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.10+ x86-64 Details
aiohttp-3.2.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
aiohttp-3.2.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
aiohttp-3.2.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
aiohttp-3.2.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
aiohttp-3.2.0-cp35-cp35m-macosx_10_12_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.12+ x86-64 Details
aiohttp-3.2.0-cp35-cp35m-macosx_10_11_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.11+ x86-64 Details
aiohttp-3.2.0-cp35-cp35m-macosx_10_10_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.10+ x86-64 Details

Total release size: 7.9 MB

Release files / aiohttp-3.2.0.tar.gz

Download URL aiohttp-3.2.0.tar.gz
Size 719.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1be3903fe6a36d20492e74efb326522dd4702bf32b45ffc7acbc0fb34ab240a6
BLAKE2b-256 checksum
How to use checksums
0e1bfd86244ef0c1c6c18581a7cbd37535f8a59054e73fbd52227c37b1c5a0d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp36-cp36m-win_amd64.whl

Download URL aiohttp-3.2.0-cp36-cp36m-win_amd64.whl
Size 419.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
8aa12ad9cccbdf0f896dd3f1bbe78093b09eb1a456cbd7208080c2c0e9c338e1
BLAKE2b-256 checksum
How to use checksums
2a17f234a648ee32e5fe8cdd15db893c21b5c7dab302e6d903c8aa13ff310cc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp36-cp36m-win32.whl

Download URL aiohttp-3.2.0-cp36-cp36m-win32.whl
Size 405.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
57854a9e1f0ed26acfd5765caa5522679b6e78a4dfcd137855cd058fdae5abe2
BLAKE2b-256 checksum
How to use checksums
9ec556af4b0fcb6473dc0620e513c6b5ece58fc6ce34078573fc021c00b513de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL aiohttp-3.2.0-cp36-cp36m-manylinux1_x86_64.whl
Size 761.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
695dc053980c9ad73030d426de40d7d0c66f4226c698b1c68ae94b9b761f28bd
BLAKE2b-256 checksum
How to use checksums
fffb33dd1b634c1aa837afce8aa259a83d6b294581442d727f13a3baf39f608c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp36-cp36m-manylinux1_i686.whl

Download URL aiohttp-3.2.0-cp36-cp36m-manylinux1_i686.whl
Size 735.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
af183773b170da552bfb1f78bc84647e3f7316ff5c77ae379e34362ffbafed0b
BLAKE2b-256 checksum
How to use checksums
817eaf3ecef7ad5e216efc55111043bfa600127207ea477b0604999e2d6a6b1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp36-cp36m-macosx_10_12_x86_64.whl

Download URL aiohttp-3.2.0-cp36-cp36m-macosx_10_12_x86_64.whl
Size 421.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ee39b92c1dc2425784b424bd442bd255f31e272546be92a28035dabe9da3495e
BLAKE2b-256 checksum
How to use checksums
81db93769be1bc3d1dc58b859f11a1e2eb2d1db0a8927d00ffa626ce0df70f4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp36-cp36m-macosx_10_11_x86_64.whl

Download URL aiohttp-3.2.0-cp36-cp36m-macosx_10_11_x86_64.whl
Size 429.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.11+ x86-64
SHA-256 checksum
How to use checksums
233b9a7816d29700e4ae6e024e0cc5d9d6fbd2a9b0878d0c89b75fa708a8b204
BLAKE2b-256 checksum
How to use checksums
5e4702b2e08e41b25c209051ae1069743395d15bddd7a98ca5a736a7fe1a184c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp36-cp36m-macosx_10_10_x86_64.whl

Download URL aiohttp-3.2.0-cp36-cp36m-macosx_10_10_x86_64.whl
Size 431.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.10+ x86-64
SHA-256 checksum
How to use checksums
424ad41a5434c25920fc8d0ce24c2f8d749965bce8996b86c9be0cd50f0051b2
BLAKE2b-256 checksum
How to use checksums
5dc051a3ac413149913a7dab019e5b5bb464c4e7fc04868515158e59dcc7ba6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp35-cp35m-win_amd64.whl

Download URL aiohttp-3.2.0-cp35-cp35m-win_amd64.whl
Size 417.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
51652ba1310e5a71a20133976ae6cbe301edce3387c6d3df4a8451841af8c9c7
BLAKE2b-256 checksum
How to use checksums
3cd3aff2e50a3233271581963531b6406f2291129b7321faef3d47062d71b048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp35-cp35m-win32.whl

Download URL aiohttp-3.2.0-cp35-cp35m-win32.whl
Size 403.9 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
b6abeb48f66ac26690fb681cc3c1f9eed1d2f9f29b7cd4f3e182d3276001f663
BLAKE2b-256 checksum
How to use checksums
d247d063068486ae7e096d0160452c0101ce50c4fb2e3b43d4b612eb9994954d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp35-cp35m-manylinux1_x86_64.whl

Download URL aiohttp-3.2.0-cp35-cp35m-manylinux1_x86_64.whl
Size 745.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
ef885a19bcff2a20ae0362ab6b8f8ac62b8bd8490dd3e031f15933abbe41d2b2
BLAKE2b-256 checksum
How to use checksums
059aeded1423b19063c8a06457a0bfd69a070b320f1fba67797449e65dc7ffa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp35-cp35m-manylinux1_i686.whl

Download URL aiohttp-3.2.0-cp35-cp35m-manylinux1_i686.whl
Size 720.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
4af32e7641f8029fd2cb6b3d3e51e92074ae0d42347d56e93b25fbb3f49a43bb
BLAKE2b-256 checksum
How to use checksums
929c2bf432249bb57bf87e07842b458fac130d44dd7d8fb536154ac3edf46bc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp35-cp35m-macosx_10_12_x86_64.whl

Download URL aiohttp-3.2.0-cp35-cp35m-macosx_10_12_x86_64.whl
Size 420.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
7dc80c5984613a30a6608718a401143598f69907770a46e5b6df87c7b9d06ce8
BLAKE2b-256 checksum
How to use checksums
60e0019b121318c065e26cdae8ecc9e6f40a32a9dcbee9669d3d5f80b98b13a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp35-cp35m-macosx_10_11_x86_64.whl

Download URL aiohttp-3.2.0-cp35-cp35m-macosx_10_11_x86_64.whl
Size 427.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.11+ x86-64
SHA-256 checksum
How to use checksums
46c004a3bd91c42caa1bb9c4d44ef156ccf0d7f56272590da8d066710e7c63be
BLAKE2b-256 checksum
How to use checksums
7f3d357cc50078db44388b1f451fda586a45bb852aaf4cd876808c481cfaa6d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aiohttp-3.2.0-cp35-cp35m-macosx_10_10_x86_64.whl

Download URL aiohttp-3.2.0-cp35-cp35m-macosx_10_10_x86_64.whl
Size 429.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.10+ x86-64
SHA-256 checksum
How to use checksums
b034ab3a8e328705625467fe7b3a59e23da6952ba19b5a14b044aef206b653fa
BLAKE2b-256 checksum
How to use checksums
4abdf57b6d6bb99df7d82b68f48a1713cf3dd6d5fc3e711e1e5c205ad1a81da0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.9.5

76 release files

3.9.4

76 release files

3.9.3

76 release files

3.9.2

76 release files

3.9.1

76 release files

3.9.0

76 release files

3.8.5

87 release files

3.8.4

87 release files

3.8.3

87 release files

3.8.2

87 release files

3.8.1

72 release files

3.8.0

72 release files

3.7.4

37 release files

3.7.3

37 release files

3.7.2

33 release files

3.7.1

33 release files

3.7.0

33 release files

3.6.3

13 release files

3.6.1

13 release files

3.5.4

22 release files

3.5.3

22 release files

3.5.1

22 release files

3.5.0

22 release files

3.4.1

22 release files

3.4.0

22 release files

3.3.2

15 release files

3.3.0

9 release files

3.2.1

15 release files

This release

3.2.0 This release

15 release files

3.1.3

15 release files

3.1.1

15 release files

3.1.0

15 release files

3.0.9

15 release files

3.0.8

14 release files

3.0.5

15 release files

3.0.4

15 release files

3.0.3

15 release files

3.0.2

15 release files

3.0.1

15 release files

3.0.0

11 release files

2.3.9

16 release files

2.3.8

16 release files

2.3.7

22 release files

2.3.5

22 release files

2.3.4

22 release files

2.3.3

22 release files

2.3.1

22 release files

2.3.0

13 release files

2.2.0

13 release files

2.1.0

13 release files

2.0.7

8 release files

2.0.5

13 release files

2.0.4

13 release files

2.0.3

13 release files

2.0.2

13 release files

2.0.1

13 release files

2.0.0

13 release files

1.3.5

7 release files

1.3.4

7 release files

1.3.3

13 release files

1.3.2

13 release files

1.3.0

9 release files

1.2.0

9 release files

1.1.6

9 release files

1.1.5

9 release files

1.1.4

9 release files

1.1.3

9 release files

1.1.2

9 release files

1.1.1

9 release files

1.1.0

9 release files

1.0.5

9 release files

1.0.3

9 release files

1.0.2

9 release files

1.0.1

9 release files

1.0.0

9 release files

0.22.4

9 release files

0.22.3

9 release files

0.22.2

9 release files

0.22.1

9 release files

0.22.0

9 release files

0.21.5

5 release files

0.21.4

5 release files

0.21.2

5 release files

0.21.1

5 release files

0.20.2

1 release file

0.20.1

1 release file

0.20.0

1 release file

0.19.0

1 release file

0.18.4

1 release file

0.18.3

1 release file

0.18.2

1 release file

0.18.1

1 release file

0.18.0

1 release file

0.17.4

1 release file

0.17.3

1 release file

0.17.2

1 release file

0.17.1

1 release file

0.17.0

1 release file

0.16.6

1 release file

0.16.5

1 release file

0.16.4

1 release file

0.16.3

1 release file

0.16.2

1 release file

0.16.1

1 release file

0.16.0

1 release file

0.15.3

1 release file

0.15.2

1 release file

0.15.1

1 release file

0.15.0

1 release file

0.14.4

1 release file

0.14.3

1 release file

0.14.2

1 release file

0.14.1

1 release file

0.14.0

1 release file

0.13.1

2 release files

0.13.0

2 release files

0.12.0

1 release file

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

1 release file

0.9.0

1 release file

0.8.4

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.5

1 release file

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page