APIs fail. Rate limits hit. Networks flake. This wraps your HTTP calls with production-grade resilience without any setup ceremony.
The Problem
Every agent hits external APIs. Raw requests calls have no retry logic, no rate limit handling, no circuit breaking. When the Brave Search API returns a 429, most agents just crash.
The Solution
Resilient API Client wraps any HTTP call with automatic retries, exponential backoff, jitter, circuit breaker, and rate limit header parsing — all configurable.
Features:
- Exponential backoff with jitter
- Configurable retry count and base delay
- Circuit breaker (opens after N consecutive failures)
- Rate limit header parsing (
X-RateLimit-*,Retry-After) - Timeout handling
- Response validation hooks
Usage
from resilient_api_client import ResilientClient
client = ResilientClient(
max_retries=3,
base_delay=1.0,
circuit_breaker_threshold=5,
)
response = client.get("https://api.example.com/data")
data = response.json()
Status
✅ Complete — 5/5 tests passing
No external dependencies (optional: requests). Python 3.9+. MIT License.