Asynchronous requests package
Project description
areq
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
httpxfor modern async/await support - 🔄 Drop-in Replacement: Compatible with
requestsAPI, making migration easy - 🛠 Type Hints: Full type support for better IDE integration and code safety
- 📦 Lightweight: Minimal dependencies, just
httpxandrequests
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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42acfa489478fd2846555ead938106628b1c8fac479b2a2c07415bc4671c8e6b
|
|
| MD5 |
59a69ed47dce3bf06ddd32188a22f944
|
|
| BLAKE2b-256 |
c8d12359dd7963869aed9a14d2fbc67e995d9c38d8a15a88779394197062c903
|
Provenance
The following attestation bundles were made for areq-0.0.5.tar.gz:
Publisher:
python-publish.yml on ganesh-palanikumar/areq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
areq-0.0.5.tar.gz -
Subject digest:
42acfa489478fd2846555ead938106628b1c8fac479b2a2c07415bc4671c8e6b - Sigstore transparency entry: 236012969
- Sigstore integration time:
-
Permalink:
ganesh-palanikumar/areq@9be0d2e00d08bee09b6d495db1143fe9579db825 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ganesh-palanikumar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9be0d2e00d08bee09b6d495db1143fe9579db825 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36fa8c96e4becc18151d03e6c9800e617455a716b4757a34f51d75ad477b9c67
|
|
| MD5 |
537205ccad738c0a751a338bba57bf41
|
|
| BLAKE2b-256 |
accee105e715e089781c76893a43688e8a04f94244077c31cabef3da4dc006b8
|
Provenance
The following attestation bundles were made for areq-0.0.5-py3-none-any.whl:
Publisher:
python-publish.yml on ganesh-palanikumar/areq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
areq-0.0.5-py3-none-any.whl -
Subject digest:
36fa8c96e4becc18151d03e6c9800e617455a716b4757a34f51d75ad477b9c67 - Sigstore transparency entry: 236012977
- Sigstore integration time:
-
Permalink:
ganesh-palanikumar/areq@9be0d2e00d08bee09b6d495db1143fe9579db825 -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/ganesh-palanikumar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9be0d2e00d08bee09b6d495db1143fe9579db825 -
Trigger Event:
release
-
Statement type: