lily_website

📄 API Client

⬅️ Back 🏠 Docs Root

The BaseApiClient is an asynchronous HTTP client wrapper built on top of httpx. It provides a standardized way for the Telegram Bot to communicate with external services (primarily the Django Backend API).

🏗️ Class: BaseApiClient

Located in: src/telegram_bot/core/api_client.py

Constructor

def __init__(self, base_url: str, api_key: str | None = None, timeout: float = 10.0)

Methods

_request (Internal)

An asynchronous method to perform HTTP requests.

⚠️ Error Handling

The client uses a custom exception ApiClientError to wrap various underlying issues:

📝 Usage Example

client = BaseApiClient(base_url="https://api.example.com", api_key="secret")
data = await client._request("GET", "/v1/data")