# httpx.HTTPStatusError: Client error '429 Too Many Requests' for url 'https://api.example.com/v1/data'

- **ID:** `python/httpx-httpstatuserror-429`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The server is rate-limiting the client due to excessive requests in a short time.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Implement exponential backoff and retry logic** (90% success)
   ```
   import time
for attempt in range(5):
    try:
        response = httpx.get('https://api.example.com/v1/data')
        response.raise_for_status()
        break
    except httpx.HTTPStatusError as e:
        if e.response.status_code == 429:
            time.sleep(2 ** attempt)
        else:
            raise
   ```
2. **Add a custom User-Agent header to identify your application** (60% success)
   ```
   headers = {'User-Agent': 'MyApp/1.0'}
httpx.get('https://api.example.com/v1/data', headers=headers)
   ```

## Dead Ends

- **Retrying immediately with the same request** — Retrying without delay will likely hit the same rate limit again. (95% fail)
- **Ignoring the error and continuing to send requests** — The server may temporarily block the client after repeated violations. (80% fail)
