Skip to main content

aiohttp client

Tests Published Coverage Status PyPi version PyPI - Python Version PyPI - Downloads PyPI - License

What is the difference from aiohttp.Client?

It is simpler and as a Requests


Install:

pip install aio-clients

Example:

Base reqeust:

import asyncio
from aio_clients import Http, Options


async def main():
    r = await Http().get('https://google.com', o=Options(is_json=False, is_close_session=True))
    print(f'code={r.code} body={r.body}')


asyncio.run(main())

Async reqeust

import asyncio

import aiohttp
from aio_clients import Http, Options


async def on_request_start(session, trace_config_ctx, params):
    print("Starting request")


async def on_request_end(session, trace_config_ctx, params):
    print("Ending request")


async def main():
    trace_config = aiohttp.TraceConfig()
    trace_config.on_request_start.append(on_request_start)
    trace_config.on_request_end.append(on_request_end)

    http = Http(
        host='https://google.com/search',
        option=Options(trace_config=trace_config, is_json=False),
    )

    r = await asyncio.gather(
        http.get(q_params={'q': 'test'}),
        http.get(q_params={'q': 'hello_world'}),
        http.get(q_params={'q': 'ping'}),
    )

    print(f'status code={[i.code for i in r]} body={[i.body for i in r]}')
    await http.close()


asyncio.run(main())

Multipart reqeust:

import asyncio
from aio_clients import Http, Options
from aio_clients.multipart import Easy, Form, File, Writer


async def main():
    with Easy('form-data') as form:
        form.add_form(Form(key='chat_id', value=12345123))
        form.add_form(Form(key='audio', value='hello world'))
        form.add_form(File(key='file', value=b'hello world file', file_name='test.py'))

    r = await Http(option=Options(is_close_session=True, is_json=False)).post(
        'http://localhost:8081',
        form=form,
    )

    writer = Writer()
    await form.write(writer)

    print(f'code={r.code} body={r.body}')
    print(f'full body:\n{writer.buffer.decode()}')


asyncio.run(main())

Metadata

Release files for aio-clients 2.1.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 aio-clients 2.1.0
File Size Uploaded Provenance Actions
aio_clients-2.1.0.tar.gz 6.0 kB Without provenance Details for aio_clients-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aio-clients 2.1.0
File Interpreter ABI Platform Actions
aio_clients-2.1.0-py3-none-any.whl Python 3 none any Details for aio_clients-2.1.0-py3-none-any.whl

Total release size: 13.3 kB

Release files / aio_clients-2.1.0.tar.gz

Download URL aio_clients-2.1.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e15ab3450ce64d877ea0d4426147d6b2149e5d9beaac18bb1d38977223fdf7d1
BLAKE2b-256 checksum
How to use checksums
e579a08cd1d01df2a1c4b5a9a92f0f18dbc6906cf30cb097544f1bcc988e1b29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.8 Linux/6.5.0-1017-azure

Release files / aio_clients-2.1.0-py3-none-any.whl

Download URL aio_clients-2.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19f95dc90694db1904b4ae145fd42cc55cc3f66f74641266619b286df743b650
BLAKE2b-256 checksum
How to use checksums
2f6509297298b3e25d69afcd7440ec0066bef6d2b1a31e1391a9fd35a1e41758
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.8 Linux/6.5.0-1017-azure

Security for aio-clients 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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