The missing rate-limit wrapper for aiohttp. Effortlessly handle 429s, Retry-After headers, and domain throttling for scraping and data pipelines.
Project description
HTTP Wizz 🧙♂️
The missing rate-limit wrapper for aiohttp and asyncio.
HTTP Wizz handles the hard parts of web scraping and high-volume API consumption: Strict Rate Limiting (RPS), Automatic Retries, 429/503 Backoff, and Domain Throttling. Perfect for web crawlers, data processing pipelines, and microservices.
⚡ Why HTTP Wizz?
Whether you are building a web scraper or a data pipeline (e.g., geocoding 100k addresses), hitting rate limits is the #1 cause of failure. asyncio.gather is too aggressive, and requests is too slow.
| Feature | requests |
aiohttp (raw) |
http-wizz 🧙♂️ |
|---|---|---|---|
| Async / Non-blocking | ❌ | ✅ | ✅ |
| Strict Rate Limiting (RPS) | ❌ | ❌ | ✅ |
Handle Retry-After Header |
❌ | ❌ | ✅ |
| Domain-Specific Limits | ❌ | ❌ | ✅ |
| Auto-Retries with Backoff | ❌ | ❌ | ✅ |
| Data Pipeline Friendly | ❌ | ⚠️ | ✅ |
🚀 Installation
pip install http-wizz
(Optional) For progress bars: pip install tqdm
📖 Recipes & Examples
Check out the examples/ directory for ready-to-run scripts:
- Data Pipeline: Process batches of data at a fixed speed.
- Hacker News Scraper: Fetch top stories politely.
- Strict API Consumer: Handle APIs with tight limits (e.g., 2 RPS).
- Benchmark: Compare Wizz vs Sequential vs Naive Async.
📚 API Reference
For a complete list of all parameters, flags, and advanced options, please see the Full API Reference.
🛠 Usage Guide
1. Batch Processing (The Simple Way)
Perfect for data processing pipelines where you just want to "fire and forget" a list of tasks at a safe speed.
from http_wizz import fetch_urls
urls = [f"https://api.geocoder.com/search?q={addr}" for addr in my_addresses]
# Process 1,000 items at exactly 20 requests per second
results = fetch_urls(urls, requests_per_second=20, show_progress=True)
2. High-Performance Async Client
Best for modern async applications and microservices.
import asyncio
from http_wizz import WizzClient
async def main():
# 50 RPS limit for high-throughput pipelines
async with WizzClient(requests_per_second=50, burst_size=10) as client:
results = await client.fetch_all(["https://api.com/task/1", ...])
3. The Power User Way (RateLimitedSession)
A drop-in replacement for aiohttp.ClientSession. Use this for full control (headers, cookies, POST/PUT methods, etc.).
from http_wizz import RateLimitedSession
async with RateLimitedSession(requests_per_second=5) as session:
async with session.post("https://api.com/update", json={"id": 123}) as resp:
status = await resp.json()
👮 API Compliance & Politeness
HTTP Wizz ensures your application remains a "Good Citizen" and avoids IP bans:
- Respects
Retry-After: If a service (like Google or AWS) replies with aRetry-Afterheader, HTTP Wizz automatically pauses for the required duration. - Smoothing: Uses a Token Bucket algorithm to ensure your traffic is consistent, not spikey, which is key for staying within API quotas.
- Domain Throttling: Manage multiple services with different quotas simultaneously:
client = WizzClient(
requests_per_second=10,
domain_limits={
"maps.google.com": 50, # High quota
"legacy-service.local": 1 # Very fragile service
}
)
🤝 Contributing
We love pull requests! If you have a feature idea or found a bug, please open an issue.
License: MIT
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 http_wizz-1.0.1.tar.gz.
File metadata
- Download URL: http_wizz-1.0.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ddeb1a90f14d8f3e33f42bf209fdf451b19e2ef8dd5d4b78f3056892a3e8f5d
|
|
| MD5 |
228e48081180df7fdfdcb9fd863aa2e0
|
|
| BLAKE2b-256 |
da557b01ca97ac5477152dda32ff0355a7c60318f8d3b043c9cfb13fb673f1a1
|
Provenance
The following attestation bundles were made for http_wizz-1.0.1.tar.gz:
Publisher:
publish.yml on TomMcKenna1/http-wizz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
http_wizz-1.0.1.tar.gz -
Subject digest:
9ddeb1a90f14d8f3e33f42bf209fdf451b19e2ef8dd5d4b78f3056892a3e8f5d - Sigstore transparency entry: 868634828
- Sigstore integration time:
-
Permalink:
TomMcKenna1/http-wizz@0abdd611da2a9acaa86856358180a2dec76f0a20 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/TomMcKenna1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0abdd611da2a9acaa86856358180a2dec76f0a20 -
Trigger Event:
release
-
Statement type:
File details
Details for the file http_wizz-1.0.1-py3-none-any.whl.
File metadata
- Download URL: http_wizz-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
996f06d9ae40d6d448d25741a81e31d1a4a9c4ddd04e349894c87c4ccee3bde6
|
|
| MD5 |
2638aa40cc861fc965f2a0f783121115
|
|
| BLAKE2b-256 |
aebe87b0ab0707cd6164452778cf6aabc4a70d7fadab47bb2b14bc8d92cf6888
|
Provenance
The following attestation bundles were made for http_wizz-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on TomMcKenna1/http-wizz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
http_wizz-1.0.1-py3-none-any.whl -
Subject digest:
996f06d9ae40d6d448d25741a81e31d1a4a9c4ddd04e349894c87c4ccee3bde6 - Sigstore transparency entry: 868634834
- Sigstore integration time:
-
Permalink:
TomMcKenna1/http-wizz@0abdd611da2a9acaa86856358180a2dec76f0a20 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/TomMcKenna1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0abdd611da2a9acaa86856358180a2dec76f0a20 -
Trigger Event:
release
-
Statement type: