ObjectStackObjectStack

Analytics

Analytics protocol schemas

Analytics API Protocol

Defines the HTTP interface for the Semantic Layer. Provides endpoints for executing analytical queries and discovering metadata.

Source: packages/spec/src/api/analytics.zod.ts

TypeScript Usage

import { AnalyticsEndpoint, AnalyticsMetadataResponseSchema, AnalyticsQueryRequestSchema, AnalyticsResultResponseSchema, AnalyticsSqlResponseSchema, GetAnalyticsMetaRequestSchema } from '@objectstack/spec/api';
import type { AnalyticsEndpoint, AnalyticsMetadataResponse, AnalyticsQueryRequest, AnalyticsSqlResponse, GetAnalyticsMetaRequest } from '@objectstack/spec/api';

// Validate data
const result = AnalyticsEndpoint.parse(data);

AnalyticsEndpoint

Allowed Values

  • /api/v1/analytics/query
  • /api/v1/analytics/meta
  • /api/v1/analytics/sql

AnalyticsMetadataResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | … +266 more>; message: string; category?: string; httpStatus?: integer; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ name: string; title?: string; measures: object[]; dimensions: object[] }[]Available cubes, each as the CubeMeta discovery projection — the cube name, its title, and the measures/dimensions a client may name in a query. A bare array: there is no cubes wrapper object, and no cube sql is published.

AnalyticsQueryRequest

Properties

PropertyTypeRequiredDescription
cubestringTarget cube name
measuresstring[]List of metrics to calculate
dimensionsstring[]optionalList of dimensions to group by
whereanyoptionalFiltering criteria (canonical Query DSL FilterCondition)
timeDimensions{ dimension: string; granularity?: Enum<'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'>; dateRange?: string | string[] }[]optional
orderRecord<string, Enum<'asc' | 'desc'>>optional
limitnumberoptional
offsetnumberoptional
timezonestringoptional
queryneveroptional[REMOVED] query was removed from AnalyticsQueryRequest in @objectstack/spec 17.0.0 (#3878). The { cube, query: {...} } envelope was the dialect of the retired degraded analytics shim (#3891) — the real engine never understood it. Move the query.* fields to the body top level: { cube, measures, dimensions?, where?, timeDimensions?, order?, limit?, offset?, timezone? }.
formatneveroptional[REMOVED] format was removed from AnalyticsQueryRequest in @objectstack/spec 17.0.0 (#3878). It was never implemented — every response is the JSON envelope. Delete the key; for CSV/XLSX use the export surface instead.

AnalyticsResultResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | … +266 more>; message: string; category?: string; httpStatus?: integer; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ rows: Record<string, any>[]; fields: object[]; sql?: string }

AnalyticsSqlResponse

Properties

PropertyTypeRequiredDescription
successbooleanOperation success status
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | … +266 more>; message: string; category?: string; httpStatus?: integer; … }optionalError details if success is false
meta{ timestamp: string; duration?: number; requestId?: string; traceId?: string }optionalResponse metadata
data{ sql: string; params: any[] }

GetAnalyticsMetaRequest

Properties

PropertyTypeRequiredDescription
cubestringoptionalOptional cube name to filter

On this page