KitaruAPIClient
Kitaru API client.
Attributes
attributebase_urlstrReturn 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) -> NoneInitialize the client.
paramselfparambase_urlstr | None= NoneServer base URL, read from KITARU_API_URL and then the stored server URL when omitted.
paramapi_keystr | None= NoneAPI 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= NoneStore 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.0Request timeout in seconds.
paramretriesint= 3Retry count for failed requests.
parampool_sizeint= 20Connection pool size.
paramanalytics_sourceAnalyticsSource= AnalyticsSource.PYTHONClient sending the requests.
Returns
Nonefuncwith_token(self, token) -> KitaruAPIClientReturn a view of this client authenticating with a fixed bearer token.
paramselfparamtokenstrBearer token attached to every request sent through the view.
Returns
kitaru.client.KitaruAPIClientClient view authenticating with the given token.
funcwith_auth(self, auth) -> KitaruAPIClientReturn 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.
paramselfparamauthTokenAuthAuth flow attached to every request sent through the view.
Returns
kitaru.client.KitaruAPIClientClient view authenticating with the given auth flow.
funcwith_options(self, consistency=None) -> KitaruAPIClientReturn 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.
paramselfparamconsistencyLiteral['strong'] | None= Nonestrong 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.KitaruAPIClientClient 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.ResponseSend a request and raise a typed error on failure.
paramselfparammethodstrHTTP method.
parampathstrRequest path relative to the base URL.
paramparamsdict[str, Any] | None= NoneQuery parameters.
paramjsonAny= NoneJSON request body.
paramdatadict[str, str] | None= NoneForm request body.
paramfilesdict[str, tuple[str | None, bytes, str]] | None= NoneMultipart file fields, filename/content/content-type per field.
paramcontentbytes | AsyncIterable[bytes] | None= NoneRaw or streaming request body.
paramheadersdict[str, str] | None= NoneAdditional request headers.
paramidempotency_keystr | None= NoneIdempotency key overriding the transport's random default.
paramauthenticatebool= TrueWhether to send the request through this client's auth flow. The login endpoints send their own credential.
Returns
httpx.ResponseHTTP response.
funcclose(self) -> NoneClose the auth flow and HTTP transport this client owns.
paramselfReturns
None