All checks were successful
Build And Publish Package / publish (push) Successful in 54s
AioHTTPX
AioHTTPX is an internal async HTTP client built on top of httpx.AsyncClient, using aiohttp as the transport layer for improved async performance. It also adds Redis-backed rate limiting and response caching at the transport level.
What it provides
AioHTTPXClient— a drop-in replacement forhttpx.AsyncClientaiohttp-based async transport- Optional rate limiting (Redis)
- Optional response caching (Redis, TTL via headers)
Installation (internal)
Configure pip with your private index:
[global]
index-url = https://git.miwory.dev/api/packages/Miwory/pypi/simple
username = <USERNAME>
password = <PASSWORD>
Then install:
pip install aiohttpx
Usage
Basic client (no Redis)
from aiohttpx import AioHTTPXClient
async with AioHTTPXClient() as client:
r = await client.get("https://example.com")
print(r.text)
This uses:
aiohttp.ClientSessionunder the hood- httpx-compatible request / response API
Rate limiting
Rate limiting is optional and requires Redis.
client = AioHTTPXClient(
redis_url="redis://localhost:6379",
key="my-rate-limit-key",
limit=60, # requests per minute
)
How it works:
- Token-based limiting using Redis time
- Requests exceeding the limit are delayed and retried
- Implemented in
AsyncRateLimit
Response caching
Caching is also optional and Redis-backed.
client = AioHTTPXClient(
redis_url="redis://localhost:6379",
)
To enable caching for a request, set a TTL header:
await client.get(
"https://example.com/data",
headers={"X-Cache-TTL": "30"},
)
Notes:
- Cache key = method + URL
- TTL is read from
X-Cache-TTLheader - Cached responses are fully reconstructed
Responseobjects
Configuration parameters
AioHTTPXClient(...) supports all standard httpx.AsyncClient arguments plus:
| Parameter | Type | Description |
|---|---|---|
redis_url |
str | None |
Redis connection URL |
key |
str | None |
Rate limit Redis key |
limit |
int | None |
Requests per minute |
logger |
str | None |
Logger name |
Notes & limitations
- ❌ Sync client is not supported
- ❌ HTTP/2 disabled (
http1=True,http2=False) - ✅ Automatic retry on network/connect errors
Description
Languages
Python
100%