---
title: "Get Analytics"
method: POST
path: "/api/analytics"
tags: ["Analytics"]
---

# Get Analytics

`POST /api/analytics`

This route allows you to view the analytics for a dataset using a structured query.

## Headers

- `TR-Dataset` string, uuid, required

## Request body

- AnalyticsQuery — Represents a complete Analytics query with parameters
  - `columns` Column[], required — Simple columns to select
    - `aggregation` 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX'
    - `alias` string, nullable
    - `distinct` boolean, nullable
    - `name` string, required
  - `cte_query` CommonTableExpression
    - `alias` string, required
    - `query` SubQuery, required — Represents a complete ClickHouse query with parameters
      - `columns` Column[], required — Simple columns to select
        - `aggregation` 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX'
        - `alias` string, nullable
        - `distinct` boolean, nullable
        - `name` string, required
      - `expressions` Expression[], nullable — Complex expressions to select
        - `alias` string, nullable
        - `expression` union, required — Structured expression type
          - object
            - `name` string, required
            - `type` 'column', required
          - object
            - `type` 'literal', required
            - `value` union, required
              - …
          - object
            - `args` ExpressionType[], required
            - `name` string, required
            - `type` 'function', required
          - object
            - `sql` string, required
            - `type` 'raw', required
      - `filter_conditions` FilterCondition[], nullable — WHERE clause conditions
        - `and_filter` FilterCondition[], nullable
        - `column` string, required
        - `operator` '=' | '!=' | '<>' | '>' | '<' | '>=' | '<=' | 'like' | 'not like' | 'in' | 'not in' | 'is null' | 'is not null', required
        - `or_filter` FilterCondition[], nullable
        - `value` union, required
          - string
          - number, double
          - boolean
          - FilterValue[]
      - `group_by` GroupBy — Represents a GROUP BY clause
        - `columns` string[], required
        - `having` union — Structured HAVING condition
          - object
            - `column` string, required
            - `function` 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX', required
            - `operator` '=' | '!=' | '<>' | '>' | '<' | '>=' | '<=' | 'like' | 'not like' | 'in' | 'not in' | 'is null' | 'is not null', required
            - `type` 'aggregate', required
            - `value` union, required
              - …
          - object
            - `conditions` HavingCondition[], required
            - `type` 'and', required
          - object
            - `conditions` HavingCondition[], required
            - `type` 'or', required
      - `joins` JoinClause[], nullable — Tables to join with
        - `condition` union, required — Structured join condition instead of raw SQL
          - object
            - `left_column` string, required
            - `right_column` string, required
            - `type` 'column_equals', required
          - object
            - `columns` string[], required
            - `type` 'using', required
        - `join_type` 'inner' | 'left' | 'right' | 'full' | 'cross' | 'anti' — Represents the type of join between tables
        - `table` union, required
          - 'search_queries'
          - 'rag_queries'
          - 'recommendations'
          - 'events'
          - 'cluster_topics'
          - 'search_cluster_memberships'
          - 'topics'
          - 'experiments'
          - 'experiment_user_assignments'
          - object
            - `Custom` string, required
      - `limit` integer, nullable — LIMIT clause
      - `offset` integer, nullable — OFFSET clause
      - `order_by` OrderBy
        - `columns` string[], required
        - `direction` 'asc' | 'desc'
      - `table` union, required
        - 'search_queries'
        - 'rag_queries'
        - 'recommendations'
        - 'events'
        - 'cluster_topics'
        - 'search_cluster_memberships'
        - 'topics'
        - 'experiments'
        - 'experiment_user_assignments'
        - object
          - `Custom` string, required
  - `expressions` Expression[], nullable — Complex expressions to select
    - `alias` string, nullable
    - `expression` union, required — Structured expression type
      - object
        - `name` string, required
        - `type` 'column', required
      - object
        - `type` 'literal', required
        - `value` union, required
          - string
          - number, double
          - boolean
          - FilterValue[]
      - object
        - `args` ExpressionType[], required
        - `name` string, required
        - `type` 'function', required
      - object
        - `sql` string, required
        - `type` 'raw', required
  - `filter_conditions` FilterCondition[], nullable — WHERE clause conditions
    - `and_filter` FilterCondition[], nullable
    - `column` string, required
    - `operator` '=' | '!=' | '<>' | '>' | '<' | '>=' | '<=' | 'like' | 'not like' | 'in' | 'not in' | 'is null' | 'is not null', required
    - `or_filter` FilterCondition[], nullable
    - `value` union, required
      - string
      - number, double
      - boolean
      - FilterValue[]
  - `group_by` GroupBy — Represents a GROUP BY clause
    - `columns` string[], required
    - `having` union — Structured HAVING condition
      - object
        - `column` string, required
        - `function` 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX', required
        - `operator` '=' | '!=' | '<>' | '>' | '<' | '>=' | '<=' | 'like' | 'not like' | 'in' | 'not in' | 'is null' | 'is not null', required
        - `type` 'aggregate', required
        - `value` union, required
          - string
          - number, double
          - boolean
          - FilterValue[]
      - object
        - `conditions` HavingCondition[], required
        - `type` 'and', required
      - object
        - `conditions` HavingCondition[], required
        - `type` 'or', required
  - `joins` JoinClause[], nullable — Tables to join with
    - `condition` union, required — Structured join condition instead of raw SQL
      - object
        - `left_column` string, required
        - `right_column` string, required
        - `type` 'column_equals', required
      - object
        - `columns` string[], required
        - `type` 'using', required
    - `join_type` 'inner' | 'left' | 'right' | 'full' | 'cross' | 'anti' — Represents the type of join between tables
    - `table` union, required
      - 'search_queries'
      - 'rag_queries'
      - 'recommendations'
      - 'events'
      - 'cluster_topics'
      - 'search_cluster_memberships'
      - 'topics'
      - 'experiments'
      - 'experiment_user_assignments'
      - object
        - `Custom` string, required
  - `limit` integer, nullable — LIMIT clause
  - `offset` integer, nullable — OFFSET clause
  - `order_by` OrderBy
    - `columns` string[], required
    - `direction` 'asc' | 'desc'
  - `table` union, required
    - 'search_queries'
    - 'rag_queries'
    - 'recommendations'
    - 'events'
    - 'cluster_topics'
    - 'search_cluster_memberships'
    - 'topics'
    - 'experiments'
    - 'experiment_user_assignments'
    - object
      - `Custom` string, required

## Response `200`

The analytics for the dataset

- unknown

---

[API](https://skmtc.net/devflowinc/apis/trieve-api.md) · [All operations](https://skmtc.net/devflowinc/apis/trieve-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/devflowinc/trieve-api/revisions/84583e7c9fc1/schema)
