Skip to main content

Retry After

A lightweight, dependency-free Python decorator to automatically handle HTTP 429 Rate Limits and respect Retry-After headers. Built for modern APIs, web scrapers etc, supporting both sync and async clients.

Table of contents

Quick Start

Synchronous Client

import httpx
from retryafter import auto_retry

@auto_retry(max_attempts=3, default_wait=2.0)
def fetch_api_data(url: str) -> dict:
    response = httpx.get(url)
    response.raise_for_status()  # This triggers the retry logic on 429
    return response.json()

Asynchronous Client

import httpx
import anyio
from retryafter import auto_retry

@auto_retry(max_attempts=5)
async def fetch_api_data_async(url: str) -> dict:
    async with httpx.AsyncClient() as client:
        response = await client.get(url)
        response.raise_for_status()
        return response.json()

Configuration

You can customize the decorator behavior using the following parameters:

Parameter Type Default Description
max_attempts int 3 The maximum number of attempts before raising the original exception.
default_wait float 2.0 Fallback wait time (in seconds) if the server does not return a Retry-After header.
reraise bool True If True, bubbles up the original httpx.HTTPStatusError instead of tenacity's RetryError.

License

MIT License © 2026 Dawid Wielechowski

Metadata

Release files for retryafter 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for retryafter 0.2.0
File Size Uploaded
retryafter-0.2.0.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for retryafter 0.2.0
File Interpreter ABI Platform
retryafter-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.7 kB

Release files / retryafter-0.2.0.tar.gz

Download URL retryafter-0.2.0.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0f24bdcf8582a6dc1752153406077aaf364016a02b32efe6091ea33ef06f0ebe
BLAKE2b-256 checksum
How to use checksums
0eb7b391cd1dcd9bfabb4f09f36aa5a217bd336367f9fc12635e53b56081f1bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / retryafter-0.2.0-py3-none-any.whl

Download URL retryafter-0.2.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a72094da2dfa1c7e7ddc255ca29f98624eb4652c7c24b41337bde8b2cd9a5b4
BLAKE2b-256 checksum
How to use checksums
dc9a71b5ad481207aa2726e2d1fcfe1a95deec10ea709dd2e0cf7ae22f68a3d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page