TypeScript SDK
The official TypeScript/JavaScript SDK for the KLIQ AI API. Full type safety, auto-pagination, and automatic token refresh.
npm install @kliq-ai/sdk
KliqClient
The root client. Create one per application.
new KliqClient(config)
| Property | Type | Required | Description |
|---|---|---|---|
| apiKey | string | No | API key for authentication |
| accessToken | string | No | JWT access token |
| clientId | string | No | OAuth2 client ID |
| clientSecret | string | No | OAuth2 client secret |
| baseUrl | string | No | API base URL. Default: https://api.kliqpulse.com/v1 |
| timeout | number | No | Request timeout in ms. Default: 30000 |
Methods
| Method | Returns | Description |
|---|---|---|
forTenant(tenantId: string) | KliqTenantClient | Create a tenant-scoped client |
auth.getToken(credentials) | Promise<AuthTokens> | Exchange credentials for JWT tokens |
auth.refresh(refreshToken) | Promise<AuthTokens> | Refresh an expired token |
verticals.list() | Promise<PaginatedResponse<Vertical>> | List all public verticals |
verticals.get(slug) | Promise<Vertical> | Get a vertical by slug |
verticals.create(tenantId, params) | Promise<Vertical> | Create a custom vertical |
gradingSchemas.listForVertical(slug) | Promise<PaginatedResponse<GradingSchema>> | List schemas for a vertical |
gradingSchemas.get(id) | Promise<GradingSchema> | Get a schema with attributes |
gradingSchemas.create(tenantId, params) | Promise<GradingSchema> | Create a custom schema |
catalog.categories.list(verticalSlug) | Promise<PaginatedResponse<CatalogCategory>> | List catalog categories |
catalog.types.list(categorySlug) | Promise<PaginatedResponse<CatalogType>> | List types in a category |
catalog.types.gradingGuide(typeSlug) | Promise<GradingGuide> | Get grading guides for a type |
catalog.items.list(typeSlug) | Promise<PaginatedResponse<CatalogItem>> | List items in a type |
catalog.items.get(id) | Promise<CatalogItem> | Get a single catalog item |
catalog.items.search(params) | Promise<PaginatedResponse<CatalogItem>> | Search items by name |
catalog.items.create(tenantId, params) | Promise<CatalogItem> | Add a private catalog item |
import { KliqClient } from '@kliq-ai/sdk';
const kliq = new KliqClient({
apiKey: process.env.KLIQ_API_KEY!,
});
const tenant = kliq.forTenant('t_abc123');
KliqTenantClient
Tenant-scoped client with access to all resource APIs.
Properties
| Property | Type | Description |
|---|---|---|
observations | Observations | Observation CRUD and listing |
locations | Locations | Location management |
catalog | TrackedObjects | SKU/product catalog |
cv | CvJobs | Computer vision job management |
webhooks | Webhooks | Webhook subscription management |
buildings | Buildings | Building management (BuildingScan) |
assets | Assets | Asset management (BuildingScan) |
visits | Visits | Visit/inspection tracking |
inspections | Inspections | Inspection lifecycle (via tenant client) |
Observations
observations.create(input)
CreateObservationInput
| Property | Type | Required | Description |
|---|---|---|---|
| locationId | string | Yes | ID of the location |
| imageUrl | string | Yes | URL of the image to analyze |
| latitude | number | No | GPS latitude |
| longitude | number | No | GPS longitude |
| metadata | Record<string, any> | No | Arbitrary key-value metadata |
Returns: Promise<Observation>
observations.get(id)
Get a single observation by ID. Returns: Promise<Observation>
observations.list(params?)
ListObservationsParams
| Property | Type | Required | Description |
|---|---|---|---|
| locationId | string | No | Filter by location |
| status | string | No | Filter by status |
| cursor | string | No | Pagination cursor |
| limit | number | No | Items per page (1-100). Default: 20 |
Returns: Promise<PaginatedResponse<Observation>>
observations.listAll(params?)
Auto-paginating async iterator. Returns: AsyncIterable<Observation>
for await (const obs of tenant.observations.listAll({ status: 'completed' })) {
console.log(obs.id, obs.status);
}
observations.createBatch(inputs)
Create multiple observations at once. Returns: Promise<Observation[]>
observations.delete(id)
Delete an observation. Returns: Promise<void>
observations.getUploadUrl(params)
Get a signed URL for direct image upload. Returns: Promise<{ uploadUrl: string; imageUrl: string }>
Locations
locations.create(input)
CreateLocationInput
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Human-readable location name |
| address | string | No | Physical address |
| latitude | number | No | GPS latitude |
| longitude | number | No | GPS longitude |
| metadata | Record<string, any> | No | Arbitrary metadata |
Returns: Promise<Location>
locations.get(id) / locations.list(params?) / locations.update(id, input) / locations.delete(id)
Standard CRUD operations with the same pagination pattern.
CvJobs
cv.start(input)
StartCvJobInput
| Property | Type | Required | Description |
|---|---|---|---|
| observationId | string | Yes | Observation to analyze |
| model | string | Yes | CV model to use (e.g. shelf-detection-v2) |
| options | Record<string, any> | No | Model-specific options |
Returns: Promise<CvJob>
cv.get(id)
Returns: Promise<CvJob>
cv.waitForCompletion(id, options?)
Polls until the job completes or fails. Returns: Promise<CvJob>
| Option | Type | Default | Description |
|---|---|---|---|
timeoutMs | number | 120000 | Maximum wait time in ms |
pollIntervalMs | number | 2000 | Time between polls |
cv.list(params?)
Returns: Promise<PaginatedResponse<CvJob>>
Webhooks
webhooks.create(input)
CreateWebhookInput
| Property | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | HTTPS endpoint to receive events |
| events | string[] | Yes | Event types to subscribe to |
| secret | string | No | Signing secret for HMAC verification |
Returns: Promise<Webhook>
webhooks.list() / webhooks.delete(id)
Standard list and delete operations.
TrackedObjects (Catalog)
catalog.create(input) / catalog.import(config) / catalog.list(params?)
Manage the SKU/product catalog for CV model matching.
Verticals
verticals.list()
Returns: Promise<PaginatedResponse<Vertical>>
verticals.get(slug)
Returns: Promise<Vertical>
verticals.create(tenantId, params)
const vertical = await kliq.verticals.create('t_abc123', {
slug: 'acme-wine-scan',
name: 'WineScan',
description: 'Fine wine authentication and condition grading.',
brandColor: '#722F37',
});
Returns: Promise<Vertical>
Grading Schemas
gradingSchemas.listForVertical(slug)
Returns: Promise<PaginatedResponse<GradingSchema>>
gradingSchemas.get(id)
Returns: Promise<GradingSchema> — includes the attributes array.
gradingSchemas.create(tenantId, params)
const schema = await kliq.gradingSchemas.create('t_abc123', {
verticalSlug: 'acme-wine-scan',
slug: 'parker-100-point',
name: 'Parker 100-Point Scale',
standard: 'Robert Parker / Wine Advocate',
overallFormula: { method: 'weighted_average', weightField: 'weight' },
attributes: [
{ key: 'aroma', name: 'Aroma', type: 'scale', config: { min: 0, max: 15, step: 1 }, weight: 0.15, required: true },
{ key: 'flavor', name: 'Flavor', type: 'scale', config: { min: 0, max: 20, step: 1 }, weight: 0.20, required: true },
],
});
Returns: Promise<GradingSchema>
Catalog
catalog.categories.list(verticalSlug)
Returns: Promise<PaginatedResponse<CatalogCategory>>
catalog.types.list(categorySlug) / catalog.types.gradingGuide(typeSlug)
Returns grading guide descriptions and AI prompt hints for each attribute grade value.
catalog.items.list(typeSlug) / catalog.items.get(id) / catalog.items.search(params)
// Search across all public items
const results = await kliq.catalog.items.search({ search: 'charizard' });
// Get a specific item
const card = await kliq.catalog.items.get('pkmn-base-charizard-holo-4');
console.log(card.type.gradingSchemaSlug); // "psa-10-point"
catalog.items.create(tenantId, params)
Creates a private catalog item scoped to the tenant.
Returns: Promise<CatalogItem>
Inspections
Inspections are accessed via the tenant client: kliq.forTenant(id).inspections.
inspections.create(params)
const inspection = await tenant.inspections.create({
catalogItemSlug: 'pkmn-base-charizard-holo-4',
gradingSchemaSlug: 'psa-10-point',
notes: 'Submitted by collector.',
});
Returns: Promise<Inspection>
inspections.list(params?)
Returns: Promise<PaginatedResponse<Inspection>>
inspections.get(id)
Returns: Promise<Inspection> — includes aiGrades, finalGrades, and status.
inspections.grade(id)
Triggers the AI grading pipeline. Returns: Promise<{ jobId: string; status: string }>
inspections.submitHumanGrades(id, params)
const finalized = await tenant.inspections.submitHumanGrades(inspection.id, {
grades: { centering: 8, corners: 9, edges: 9, surface: 9 },
notes: 'Minor centering offset on left border.',
});
console.log(finalized.finalGrades.overall); // 8.75
console.log(finalized.status); // "completed"
Returns: Promise<Inspection>
Buildings (BuildingScan)
buildings.create(input) / buildings.get(id) / buildings.list(params?) / buildings.update(id, input)
Manage buildings for inspection workflows.
Assets (BuildingScan)
assets.create(input) / assets.get(id) / assets.list(params?) / assets.update(id, input)
Manage individual building assets/components.
Visits
visits.create(input) / visits.get(id) / visits.list(params?)
Track inspection visits and link them to observations.
Types
Observation
interface Observation {
id: string;
tenantId: string;
locationId: string;
imageUrl: string;
latitude?: number;
longitude?: number;
status: 'pending' | 'processing' | 'completed' | 'failed';
metadata: Record<string, any>;
createdAt: string;
updatedAt: string;
}
CvJob
interface CvJob {
id: string;
observationId: string;
model: string;
status: 'queued' | 'processing' | 'completed' | 'failed';
result?: {
detections: Detection[];
summary: Record<string, any>;
};
error?: string;
createdAt: string;
completedAt?: string;
}
Detection
interface Detection {
objectName: string;
confidence: number;
boundingBox: { x: number; y: number; width: number; height: number };
attributes: Record<string, any>;
}
PaginatedResponse
interface PaginatedResponse<T> {
data: T[];
cursor: {
next: string | null;
hasMore: boolean;
};
}