---
title: Analytics
description: Analytics protocol schemas
---

{/* ⚠️  AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs go in content/docs/guides/. */}

Analytics API Protocol

Defines the HTTP interface for the Semantic Layer.

Provides endpoints for executing analytical queries and discovering metadata.

<Callout type="info">
**Source:** `packages/spec/src/api/analytics.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { AnalyticsEndpoint, AnalyticsMetadataResponse, AnalyticsQueryRequest, AnalyticsResultResponse, AnalyticsSqlResponse, GetAnalyticsMetaRequest } from '@objectstack/spec/api';
import type { AnalyticsEndpoint, AnalyticsMetadataResponse, AnalyticsQueryRequest, AnalyticsResultResponse, 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

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **success** | `boolean` | ✅ | Operation success status |
| **error** | `Object` | optional | Error details if success is false |
| **meta** | `Object` | optional | Response metadata |
| **data** | `Object` | ✅ |  |


---

## AnalyticsQueryRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **query** | `Object` | ✅ | The analytic query definition |
| **cube** | `string` | ✅ | Target cube name |
| **format** | `Enum<'json' \| 'csv' \| 'xlsx'>` | ✅ | Response format |


---

## AnalyticsResultResponse

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **success** | `boolean` | ✅ | Operation success status |
| **error** | `Object` | optional | Error details if success is false |
| **meta** | `Object` | optional | Response metadata |
| **data** | `Object` | ✅ |  |


---

## AnalyticsSqlResponse

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **success** | `boolean` | ✅ | Operation success status |
| **error** | `Object` | optional | Error details if success is false |
| **meta** | `Object` | optional | Response metadata |
| **data** | `Object` | ✅ |  |


---

## GetAnalyticsMetaRequest

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **cube** | `string` | optional | Optional cube name to filter |


---

