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

Uploaded Python 3

File details

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

File metadata

  • Download URL: areq-0.0.3.tar.gz
  • Upload date:
  • Size: 4.6 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.3.tar.gz
Algorithm Hash digest
SHA256 7e9832f027fa14a1b1ca2dd165dc86e550226fcbdd8c6259f87da39b5721b616
MD5 15c0681d31a74b686aa84cd5a9f5ec99
BLAKE2b-256 d6f6a43c7d284437b8aebb5c141658a087b4c39831ab6ef655250f4c94826e6e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: areq-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 01a6ae04f93af83243d863d718ff1f924a40403c7cb84ee60fa90f37e2bc1e67
MD5 4ddff700642980ccfde9d9207552577d
BLAKE2b-256 e75dcc56b8cc4147a0d19f523ebdf2e544e51edb24e12ee263acc82edd1a7213

See more details on using hashes here.

Provenance

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