Skip to main content

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 🧙‍♂️

PyPI - Version PyPI - License PyPI - Python Version Tests

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:


📚 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:

  1. Respects Retry-After: If a service (like Google or AWS) replies with a Retry-After header, HTTP Wizz automatically pauses for the required duration.
  2. Smoothing: Uses a Token Bucket algorithm to ensure your traffic is consistent, not spikey, which is key for staying within API quotas.
  3. 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

http_wizz-1.0.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

http_wizz-1.0.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

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

Hashes for http_wizz-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9ddeb1a90f14d8f3e33f42bf209fdf451b19e2ef8dd5d4b78f3056892a3e8f5d
MD5 228e48081180df7fdfdcb9fd863aa2e0
BLAKE2b-256 da557b01ca97ac5477152dda32ff0355a7c60318f8d3b043c9cfb13fb673f1a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for http_wizz-1.0.1.tar.gz:

Publisher: publish.yml on TomMcKenna1/http-wizz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for http_wizz-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 996f06d9ae40d6d448d25741a81e31d1a4a9c4ddd04e349894c87c4ccee3bde6
MD5 2638aa40cc861fc965f2a0f783121115
BLAKE2b-256 aebe87b0ab0707cd6164452778cf6aabc4a70d7fadab47bb2b14bc8d92cf6888

See more details on using hashes here.

Provenance

The following attestation bundles were made for http_wizz-1.0.1-py3-none-any.whl:

Publisher: publish.yml on TomMcKenna1/http-wizz

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