Light Logo
Python SDK (v0.16.0)Reference

api

API client module.

api module

API client module.

class API(sync_client, async_client)

Bases: object

Initializes the API with synchronous and asynchronous HTTP clients.

  • Parameters:
    • sync_client (httpx.Client) – An instance of a synchronous HTTP client.
    • async_client (httpx.AsyncClient) – An instance of an asynchronous HTTP client.

request(method, path, body=None, headers=None, params=None)

Sends a synchronous HTTP request using the configured sync client.

  • Parameters:
    • method (str) – The HTTP method to use (e.g., ‘GET’, ‘POST’).
    • path (str) – The URL path to send the request to.
    • body (Optional[JsonValue]) – The JSON body to include in the request.
    • headers (Optional[dict[str, Any]]) – Optional HTTP headers to include in the request.
    • params (Optional[Mapping[str, Any]]) – Optional query parameters.
  • Returns: The json response received from the server.
  • Return type: JsonValue

async async_request(method, path, body=None, headers=None, params=None)

Sends an asynchronous HTTP request using the configured async client.

  • Parameters:
    • method (str) – The HTTP method to use (e.g., ‘GET’, ‘POST’).
    • path (str) – The URL path to send the request to.
    • body (Optional[JsonValue]) – The JSON body to include in the request.
    • headers (Optional[dict[str, Any]]) – Optional HTTP headers to include in the request.
    • params (Optional[Mapping[str, Any]]) – Optional query parameters.
  • Returns: The json response received from the server.
  • Return type: JsonValue