Skip to content

sok.apis.base_api

Base API client implementation.

Provides the foundational BaseAPI class that all media API clients inherit from. Handles HTTP session management, request lifecycle, and connection pooling.

BaseAPI

class BaseAPI(api_key: str, base_url: str)

Bases: MediaAPI

Common base class for all API implementations.

Provides shared functionality for HTTP requests, session management, and connection handling. All specific API implementations should inherit from this class.

Initialize the API client.

Parameters

NameTypeDescription
api_keystrAPI authentication key.
base_urlstrBase URL for all API requests.
Source

Attributes

NameTypeDescription
api_keystr

API authentication key.

base_urlstr

Base URL for API requests.

api_nameproperty

str

Name of the service in error messages, from the class name.

sessionpropertywritable

Optional[aiohttp.ClientSession]

Get the HTTP session.

closeasync

async def close() -> None:

Close the aiohttp session.

Safe to call multiple times. Errors during close are silently ignored.

Source
Built with Kiln