Skip to main content

asyncreq

asyncreq is a lightweight Python library for making asynchronous HTTP requests using aiohttp. This library provides two convenient methods for interacting with RESTful APIs in an asynchronous manner.

Installation

To install the library, use the following pip command:

pip install asyncreq

Usage

make_request

The make_request method allows you to make asynchronous HTTP requests with flexible options. Here's an example of how to use it:

from asyncreq import make_request

async def example_usage():
    url = "https://api.example.com/resource"
    method = "GET"
    headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"}
    
    try:
        response_data, status_code, response_headers = await make_request(
            url=url,
            method=method,
            headers=headers,
            # Add other optional parameters as needed
        )
        print(f"Response Data: {response_data}")
        print(f"Status Code: {status_code}")
        print(f"Response Headers: {response_headers}")
    except Exception as e:
        print(f"An error occurred: {e}")

request

The request method is a simplified wrapper around make_request with added error handling. It raises appropriate exceptions for common HTTP-related errors:

from asyncreq import request, HTTPException

async def example_usage():
    url = "https://api.example.com/resource"
    method = "GET"
    headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"}
    
    try:
        response_data, status_code, response_headers = await request(
            url=url,
            method=method,
            headers=headers,
            # Add other optional parameters as needed
        )
        print(f"Response Data: {response_data}")
        print(f"Status Code: {status_code}")
        print(f"Response Headers: {response_headers}")
    except HTTPException as e:
        print(f"An HTTP error occurred: {e}")

Note: make sure to use await as demonstrated in the examples above.

Dependencies

  • aiohttp: Asynchronous HTTP client/server framework.

Contributing

If you find any issues or have suggestions for improvements, please feel free to open an issue or create a pull request on the Git repository.

License

This project is licensed under the MIT license.

Metadata

Release files for asyncreq 0.0.6

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

Source distribution (sdist)

Source distribution for asyncreq 0.0.6
File Size Uploaded Provenance
asyncreq-0.0.6.tar.gz 3.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for asyncreq 0.0.6
File Interpreter ABI Platform
asyncreq-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / asyncreq-0.0.6.tar.gz

Download URL asyncreq-0.0.6.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
964956409e92cdbf46f624078e4f728fb9e29fd98242f6160eb7e9f19e9ee525
BLAKE2b-256 checksum
How to use checksums
e33b8c9007ee7c8c37db31bfc8fc99947a99d2ee7cdc25247c1b85303930e1d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / asyncreq-0.0.6-py3-none-any.whl

Download URL asyncreq-0.0.6-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a805614209ca80276c3c5380a3dbeb93a58d8af7165632ff243b09570dc51e0
BLAKE2b-256 checksum
How to use checksums
d969e5115ac47efded6f01958293fa43384d9ec3601dd7a5fbe7b1ee3d1785e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Security for asyncreq 0.0.6

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.

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