Skip to main content

Asynchronous requests package

Project description

areq

PyPI version Python Versions License: MIT codecov

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.5.tar.gz (11.5 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.5-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: areq-0.0.5.tar.gz
  • Upload date:
  • Size: 11.5 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.5.tar.gz
Algorithm Hash digest
SHA256 42acfa489478fd2846555ead938106628b1c8fac479b2a2c07415bc4671c8e6b
MD5 59a69ed47dce3bf06ddd32188a22f944
BLAKE2b-256 c8d12359dd7963869aed9a14d2fbc67e995d9c38d8a15a88779394197062c903

See more details on using hashes here.

Provenance

The following attestation bundles were made for areq-0.0.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: areq-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.4 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 36fa8c96e4becc18151d03e6c9800e617455a716b4757a34f51d75ad477b9c67
MD5 537205ccad738c0a751a338bba57bf41
BLAKE2b-256 accee105e715e089781c76893a43688e8a04f94244077c31cabef3da4dc006b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for areq-0.0.5-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