Skip to main content

aiohttp-requests

Behold, the power of aiohttp client with Requests simplicity:

import asyncio

import aiohttp
from aiohttp_requests import requests

async def main():
    response = await requests.get('https://api.github.com', auth=aiohttp.BasicAuth('user', 'password'))
    text = await response.text()
    json = await response.json()
    return response, text, json

r, text, json = asyncio.run(main())

>>> r
<ClientResponse(https://api.github.com/) [200 OK]>
>>> r.status
200
>>> r.headers['Content-Type']
'application/json; charset=utf-8'
>>> r.get_encoding()
'utf-8'
>>> text
'{"current_user_url":"https://api.github.com/user",...'
>>> json
{'current_user_url': 'https://api.github.com/user', ... }

Plus built-in concurrency control to do multiple requests safely:

async def main():
    # Pass in a list of urls instead of just one. Optionally pass in as_iterator=True to iterate the responses.
    responses = await requests.get(['https://api.github.com'] * 2, auth=aiohttp.BasicAuth('user', 'password'))
    print(responses)    # [<ClientResponse(https://...) [200 OK]>, , <ClientResponse(https://...) [200 OK]>]

    # It defaults to 10 concurrent requests maximum. If you can handle more, then set it higher:
    requests.max_concurrency = 100

asyncio.run(main())

The requests object is just proxying get and other HTTP verb methods to aiohttp.ClientSession, which returns aiohttp.ClientResponse. To do anything else, read the aiohttp doc.

Metadata

Release files for aiohttp-requests 0.2.4

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-requests 0.2.4
File Size Uploaded
aiohttp-requests-0.2.4.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-requests 0.2.4
File Interpreter ABI Platform
aiohttp_requests-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / aiohttp-requests-0.2.4.tar.gz

Download URL aiohttp-requests-0.2.4.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
63036b83fabcf359aee33f957f7d8d12532c7d465c1343ab03a53faf38ae9e0c
BLAKE2b-256 checksum
How to use checksums
532b34ddd6fb516a8439ec5a860d7640050b49c94b64b7b134cbfbf5a21bbe17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / aiohttp_requests-0.2.4-py3-none-any.whl

Download URL aiohttp_requests-0.2.4-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d201d699748f2e1459a49e8b7e53be1d05a487f3827c201a05941139678199b8
BLAKE2b-256 checksum
How to use checksums
1b8f723efa0175d71272432566bd85739257add08bd1381799141f62596cc2c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

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