- No need to repeat the same base API URL for every request.
- Specify a base URL once, then call API endpoints using relative paths.
- Pluggable HTTP backends (httpx or CloudScraper).
This library is designed to be imported and reused across projects, providing a consistent and clean way to interact with HTTP-based APIs.
from api_forwarder import Forwarder
async def get_api():
async with Forwarder("https://api.example.com") as fw:
response = await fw.get("/v1/status")
response.raise_for_status()
print(response.json())from api_forwarder import Forwarder
async def get_api():
async with Forwarder(
"https://api.example.com",
backend="cloudscraper",
timeout=5.0,
retries=3,
retry_delay=1.0,
) as fw:
response = await fw.get("/v1/status")
response.raise_for_status()
print(response.json())