Kitaru

KitaruAPIClient

Kitaru API client.

Attributes

attributebase_urlstr

Return the server base URL this client resolved.

Functions

func__init__(self, base_url=None, api_key=None, credential_store=None, timeout=30.0, retries=3, pool_size=20, analytics_source=AnalyticsSource.PYTHON) -> None

Initialize the client.

paramself
parambase_urlstr | None
= None

Server base URL, read from KITARU_API_URL and then the stored server URL when omitted.

paramapi_keystr | None
= None

API key authenticating this client. A server key is sent as a bearer token, a control plane key is exchanged for a session token held in memory. Read from KITARU_API_TOKEN and then KITARU_API_KEY when omitted.

paramcredential_storeCredentialStore | None
= None

Store holding the credentials this client authenticates with, renewing its token as it expires. Defaults to the on-disk store when no API key is given.

paramtimeoutfloat
= 30.0

Request timeout in seconds.

paramretriesint
= 3

Retry count for failed requests.

parampool_sizeint
= 20

Connection pool size.

paramanalytics_sourceAnalyticsSource
= AnalyticsSource.PYTHON

Client sending the requests.

Returns

None
funcwith_token(self, token) -> KitaruAPIClient

Return a view of this client authenticating with a fixed bearer token.

paramself
paramtokenstr

Bearer token attached to every request sent through the view.

Returns

kitaru.client.KitaruAPIClient

Client view authenticating with the given token.

funcwith_auth(self, auth) -> KitaruAPIClient

Return a view of this client authenticating with the given auth flow.

The view shares this client's HTTP transport instead of opening a new connection pool. Closing the view closes only its auth flow, and closing this client also invalidates the view.

paramself
paramauthTokenAuth

Auth flow attached to every request sent through the view.

Returns

kitaru.client.KitaruAPIClient

Client view authenticating with the given auth flow.

funcwith_options(self, consistency=None) -> KitaruAPIClient

Return a view of this client with request options applied.

The view shares this client's HTTP transport and auth flow, and closing it leaves both open.

paramself
paramconsistencyLiteral['strong'] | None
= None

strong sends Prefer: consistency=strong on every request, so endpoints that serve reads from a replica serve the view from the primary database.

Returns

kitaru.client.KitaruAPIClient

Client view with the options applied.

funcrequest(self, method, path, params=None, json=None, data=None, files=None, content=None, headers=None, idempotency_key=None, authenticate=True) -> httpx.Response

Send a request and raise a typed error on failure.

paramself
parammethodstr

HTTP method.

parampathstr

Request path relative to the base URL.

paramparamsdict[str, Any] | None
= None

Query parameters.

paramjsonAny
= None

JSON request body.

paramdatadict[str, str] | None
= None

Form request body.

paramfilesdict[str, tuple[str | None, bytes, str]] | None
= None

Multipart file fields, filename/content/content-type per field.

paramcontentbytes | AsyncIterable[bytes] | None
= None

Raw or streaming request body.

paramheadersdict[str, str] | None
= None

Additional request headers.

paramidempotency_keystr | None
= None

Idempotency key overriding the transport's random default.

paramauthenticatebool
= True

Whether to send the request through this client's auth flow. The login endpoints send their own credential.

Returns

httpx.Response

HTTP response.

funcclose(self) -> None

Close the auth flow and HTTP transport this client owns.

paramself

Returns

None

On this page