Skip to content

CrossDarkrix/API-Forwarder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API-Forwarder

API Forwarder

Simplify API calls by sharing a base URL

Features

  • 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.

Usage

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())

Use Other Options

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())

About

Simplify API calls by sharing a base URL

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages