Skip to main content

Asynchronous requests package

Project description

areq

PyPI version Python Versions License: MIT

areq is an asynchronous drop-in replacement for the popular requests library. It provides the same familiar API as requests but with async/await support, making it perfect for modern Python applications that need to make HTTP requests efficiently.

Features

  • 🚀 Async by Default: Built on top of httpx for modern async/await support
  • 🔄 Drop-in Replacement: Compatible with requests API, making migration easy
  • 🛠 Type Hints: Full type support for better IDE integration and code safety
  • 📦 Lightweight: Minimal dependencies, just httpx and requests

Installation

pip install areq

Quick Start

import areq

# Async GET request
async def fetch_data():
    response = await areq.get("https://api.example.com/data")
    return response.json()

# Async POST request with JSON
async def create_item():
    data = {"name": "example", "value": 123}
    response = await areq.post("https://api.example.com/items", json=data)
    return response.json()

API Reference

areq provides the same methods as requests:

  • areq.get(url, **kwargs)
  • areq.post(url, **kwargs)
  • areq.put(url, **kwargs)
  • areq.delete(url, **kwargs)
  • areq.head(url, **kwargs)
  • areq.options(url, **kwargs)
  • areq.patch(url, **kwargs)
  • areq.request(method, url, **kwargs)

All methods are async and return an areq.AreqResponse object, which is compatible with requests.Response.

Response Object

The response object provides the same interface as requests.Response:

response = await areq.get("https://api.example.com/data")

# Access response data
print(response.status_code)  # HTTP status code
print(response.headers)      # Response headers
print(response.text)         # Response body as text
print(response.json())       # Parse JSON response
print(response.content)      # Raw response content

Advanced Usage

Custom Headers

headers = {"Authorization": "Bearer token123"}
response = await areq.get("https://api.example.com/data", headers=headers)

Query Parameters

params = {"page": 1, "limit": 10}
response = await areq.get("https://api.example.com/items", params=params)

File Upload

files = {"file": open("document.pdf", "rb")}
response = await areq.post("https://api.example.com/upload", files=files)

Timeout

response = await areq.get("https://api.example.com/data", timeout=5.0)

Migration from requests

If you're using requests, migrating to areq is straightforward:

# Before (requests)
import requests
response = requests.get("https://api.example.com/data")
data = response.json()

# After (areq)
import areq
async def get_data():
    response = await areq.get("https://api.example.com/data")
    data = response.json()

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Ganesh Palanikumar - @ganeshpkumar93

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

areq-0.0.4.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

areq-0.0.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file areq-0.0.4.tar.gz.

File metadata

  • Download URL: areq-0.0.4.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for areq-0.0.4.tar.gz
Algorithm Hash digest
SHA256 8b2fc040c320ad92d705a3b8d9497151a81a0b83f686dbfff9df4665e5d44d4f
MD5 c3033690d33abdab58dd08b92830481b
BLAKE2b-256 7df742910b166f7d7516d6a5e87de21070bbfcc602b2a5f9ff2c062271b3cbed

See more details on using hashes here.

Provenance

The following attestation bundles were made for areq-0.0.4.tar.gz:

Publisher: python-publish.yml on ganesh-palanikumar/areq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file areq-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: areq-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for areq-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a606abb114571526f841c8ccafcfb5b109c3f4ceca45b1ff37cb09e13477f079
MD5 89ac0a6aaf6aef4e08297d5cb9f42742
BLAKE2b-256 b7a0bbf7b9bcbb0e55c883a001111e05e8546e3f849aa5ab70f2c663ac37264e

See more details on using hashes here.

Provenance

The following attestation bundles were made for areq-0.0.4-py3-none-any.whl:

Publisher: python-publish.yml on ganesh-palanikumar/areq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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