Metadata-Version: 2.4
Name: retryafter
Version: 0.1.0
Summary: Add your description here
License-File: LICENSE
Requires-Python: >=3.13
Requires-Dist: fastapi>=0.139.0
Requires-Dist: httpx>=0.28.1
Requires-Dist: tenacity>=9.1.4
Requires-Dist: uvicorn>=0.51.0
Description-Content-Type: text/markdown

# 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](#quick-start)
- [Configuration](#configuration)
- [License](#license)

## Quick Start

### Synchronous Client

```python
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

```python
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](LICENSE) © 2026 [Dawid Wielechowski](https://github.com/dawidwielechowski)
