Connection Parameters¶
All service clients (Query, ClientController, EntitlementService, WorkloadClient, etc.) inherit from ApiClient and share a common set of connection parameters.
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
host |
str | httpx.URL | None |
INSIGHTS_URL environment variable |
Host URL for API calls. |
session |
httpx.Client | httpx.AsyncClient | None |
auto-created | Pre-built HTTP session. Pass one to skip token auth setup. |
client_id |
str | None |
INSIGHTS_CLIENT_ID environment variable |
OAuth client ID. |
client_secret |
str | None |
INSIGHTS_CLIENT_SECRET environment variable |
OAuth client secret. |
realm |
str | None |
INSIGHTS_REALM / insights |
Keycloak realm name. |
usage |
str | None |
ENTERPRISE |
Deployment type: ENTERPRISE or MICROSERVICES. |
data_format |
str | None |
application/octet-stream |
Response format. Use application/json to return JSON instead of PyKX objects. |
grant_type |
str | None |
SERVICEACCOUNT |
OAuth grant type. |
timeout |
int | None |
20 |
Token request timeout in seconds. |
auth_enabled |
bool | None |
True |
Disable to skip OAuth entirely (e.g. local dev without auth). |
redirect_host |
str | None |
— | Web host for browser-based token flow. |
redirect_port |
int | None |
— | Port for browser-based token flow. |
cache |
TokenStore | None |
— | Custom token/credential store implementation. |
is_async |
bool |
False |
Use httpx.AsyncClient instead of httpx.Client. |
headers |
dict | None |
— | Extra headers sent on every request. |
keycloak_url |
str | None |
KXI_KEYCLOAK_SVC_URL / host |
Keycloak server URL when different from host. |
retries |
int | Retry |
5 |
Number of automatic HTTP retries on failure. |
Examples¶
Connect using environment variables (INSIGHTS_URL, INSIGHTS_CLIENT_ID, INSIGHTS_CLIENT_SECRET):
from kxi.query import Query
conn = Query()
Connect with explicit credentials:
from kxi.query import Query
conn = Query(
host="https://my-deploy.kx.com",
client_id="my-client",
client_secret="my-secret",
)
Connect to an Insights SDK deployment:
conn = Query(host="http://localhost:5080", usage="MICROSERVICES")
Connect without authentication (local dev):
conn = Query(host="http://localhost:5080", auth_enabled=False)