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

# Get RAG Analytics

`POST /api/analytics/rag`

This route allows you to view the RAG analytics for a dataset.

## Headers

- `TR-Dataset` string, uuid, required

## Request body

- union
  - object
    - `filter` RAGAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `has_clicks` boolean, nullable
    - `page` integer, nullable
    - `sort_by` 'hallucination_score' | 'top_score' | 'created_at'
    - `sort_order` 'desc' | 'asc'
    - `type` 'rag_queries', required
  - object
    - `filter` RAGAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `type` 'rag_usage', required
  - object
    - `filter` RAGAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `granularity` 'minute' | 'second' | 'hour' | 'day' | 'month'
    - `type` 'rag_usage_graph', required
  - object
    - `request_id` string, uuid, required
    - `type` 'rag_query_details', required
  - object
    - `filter` RAGAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `type` 'rag_query_ratings', required
  - object
    - `filter` RAGAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `page` integer, nullable
    - `type` 'followup_queries', required
  - object
    - `filter` TopicAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `hallucination_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
      - `top_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
    - `page` integer, nullable
    - `sort_by` 'hallucination_score' | 'top_score' | 'created_at'
    - `sort_order` 'desc' | 'asc'
    - `topic_events_filter` TopicEventFilter
      - `event_names` EventNamesFilter[], required — Filter by event type
      - `inverted` boolean, required
    - `type` 'topic_queries', required
  - object
    - `topic_id` string, uuid, required
    - `type` 'topic_details', required
  - object
    - `filter` TopicAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `hallucination_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
      - `top_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
    - `granularity` 'minute' | 'second' | 'hour' | 'day' | 'month'
    - `type` 'topics_over_time', required
  - object
    - `filter` RAGAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `granularity` 'minute' | 'second' | 'hour' | 'day' | 'month'
    - `type` 'ctr_metrics_over_time', required
  - object
    - `filter` RAGAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `granularity` 'minute' | 'second' | 'hour' | 'day' | 'month'
    - `type` 'messages_per_user', required
  - object
    - `filter` RAGAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
    - `granularity` 'minute' | 'second' | 'hour' | 'day' | 'month'
    - `type` 'chat_average_rating', required
  - object
    - `filter` TopicAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `hallucination_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
      - `top_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
    - `granularity` 'minute' | 'second' | 'hour' | 'day' | 'month'
    - `type` 'chat_conversion_rate', required
  - object
    - `filter` TopicAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `hallucination_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
      - `top_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
    - `type` 'event_funnel', required
  - object
    - `topic_id` string, uuid, required
    - `type` 'events_for_topic', required
  - object
    - `direct` boolean, nullable
    - `filter` EventAnalyticsFilter — Filter to apply to the events when querying for them
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `event_type` 'view' | 'filter_clicked' | 'click' | 'add_to_cart' | 'purchase'
      - `is_conversion` boolean, nullable — Filter by conversions
      - `metadata_filter` string, nullable — Filter by metadata path i.e. path.attribute = \"value\"
      - `user_id` string, nullable — Filter by user ID
    - `granularity` 'minute' | 'second' | 'hour' | 'day' | 'month'
    - `type` 'chat_revenue', required
  - object
    - `filter` TopicAnalyticsFilter
      - `component_name` string, nullable
      - `date_range` DateRange — DateRange is a JSON object which can be used to filter chunks by a range of dates. This leverages the time_stamp field on chunks in your dataset. You can specify this if you want values in a certain range. You must provide ISO 8601 combined date and time without timezone.
        - `gt` string, nullable
        - `gte` string, nullable
        - `lt` string, nullable
        - `lte` string, nullable
      - `hallucination_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
      - `query` string, nullable
      - `query_rating` QueryRatingRange
        - `gt` integer, nullable
        - `gte` integer, nullable
        - `lt` integer, nullable
        - `lte` integer, nullable
      - `rag_type` 'chosen_chunks' | 'all_chunks'
      - `top_score` FloatRange
        - `gt` number, double, nullable
        - `gte` number, double, nullable
        - `lt` number, double, nullable
        - `lte` number, double, nullable
    - `page` integer, nullable
    - `type` 'popular_chats', required

## Response `200`

The RAG analytics for the dataset

- union
  - RagQueryResponse
    - `queries` RagQueryEvent[], required
      - `created_at` string, required
      - `dataset_id` string, uuid, required
      - `detected_hallucinations` string[], required
      - `hallucination_score` number, double, required
      - `id` string, uuid, required
      - `llm_response` string, required
      - `metadata` unknown
      - `query_rating` SearchQueryRating
        - `metadata` unknown
        - `note` string, nullable
        - `rating` integer, required
      - `rag_type` 'chosen_chunks' | 'all_chunks', required
      - `results` unknown[], required
        - unknown
      - `search_id` string, uuid, required
      - `top_score` number, float, required
      - `topic_id` string, uuid, required
      - `user_id` string, required
      - `user_message` string, required
  - RAGUsageResponse
    - `total_queries` integer, required
  - RAGUsageGraphResponse
    - `points` IntegerTimePoint[], required
      - `point` integer, required
      - `time_stamp` string, required
  - RagQueryEvent
    - `created_at` string, required
    - `dataset_id` string, uuid, required
    - `detected_hallucinations` string[], required
    - `hallucination_score` number, double, required
    - `id` string, uuid, required
    - `llm_response` string, required
    - `metadata` unknown
    - `query_rating` SearchQueryRating
      - `metadata` unknown
      - `note` string, nullable
      - `rating` integer, required
    - `rag_type` 'chosen_chunks' | 'all_chunks', required
    - `results` unknown[], required
      - unknown
    - `search_id` string, uuid, required
    - `top_score` number, float, required
    - `topic_id` string, uuid, required
    - `user_id` string, required
    - `user_message` string, required
  - RagQueryRatingsResponse
    - `total_negative_ratings` integer, required — Total number of negative RAG ratings
    - `total_positive_ratings` integer, required — Total number of positive RAG ratings
  - FollowupQueriesResponse
    - `top_queries` FollowupQuery[], required
      - `count` integer, required
      - `query` string, required
  - TopicQueriesResponse
    - `topics` ClickhouseTopicAnalyticsSummary[], required
      - `avg_hallucination_score` number, double, required
      - `avg_query_rating` number, double, nullable
      - `avg_top_score` number, double, required
      - `created_at` string, required
      - `event_names` string[], required — All event_names that are associated with the topic, may contain duplicate names
      - `id` string, uuid, required
      - `message_count` integer, required
      - `name` string, required
      - `owner_id` string, required
      - `topic_id` string, uuid, required
      - `updated_at` string, required
  - TopicDetailsResponse
    - `messages` RagQueryEvent[], required
      - `created_at` string, required
      - `dataset_id` string, uuid, required
      - `detected_hallucinations` string[], required
      - `hallucination_score` number, double, required
      - `id` string, uuid, required
      - `llm_response` string, required
      - `metadata` unknown
      - `query_rating` SearchQueryRating
        - `metadata` unknown
        - `note` string, nullable
        - `rating` integer, required
      - `rag_type` 'chosen_chunks' | 'all_chunks', required
      - `results` unknown[], required
        - unknown
      - `search_id` string, uuid, required
      - `top_score` number, float, required
      - `topic_id` string, uuid, required
      - `user_id` string, required
      - `user_message` string, required
    - `topic` TopicQuery, required
      - `created_at` string, required
      - `dataset_id` string, uuid, required
      - `id` string, uuid, required
      - `metadata` unknown
      - `name` string, required
      - `owner_id` string, required
      - `topic_id` string, uuid, required
      - `updated_at` string, required
  - TopicsOverTimeResponse
    - `points` IntegerTimePoint[], required
      - `point` integer, required
      - `time_stamp` string, required
    - `total_topics` integer, required
  - CTRMetricsOverTimeResponse
    - `points` FloatTimePoint[], required
      - `point` number, double, required
      - `time_stamp` string, required
    - `total_ctr` number, double, required
  - MessagesPerUserResponse
    - `avg_messages_per_user` number, double, required
    - `points` FloatTimePoint[], required
      - `point` number, double, required
      - `time_stamp` string, required
  - ChatAverageRatingResponse
    - `avg_chat_rating` number, double, required
    - `points` FloatTimePoint[], required
      - `point` number, double, required
      - `time_stamp` string, required
  - ChatConversionRateResponse
    - `conversion_rate` number, double, required
    - `points` FloatTimePoint[], required
      - `point` number, double, required
      - `time_stamp` string, required
  - EventNameAndCountsResponse
    - `event_names` EventNameAndCounts[], required
      - `event_count` integer, required
      - `event_name` string, required
  - EventsForTopicResponse
    - `events` EventData[], required
      - `created_at` string, required — The time the event was created.
      - `dataset_id` string, uuid, required — The unique identifier for the dataset the event is associated with.
      - `event_name` string, required — The name of the event, e.g. "Added to Cart", "Purchased", "Viewed Home Page", "Clicked", "Filter Clicked", "Followup Query".
      - `event_type` string, required — The type of event, "add_to_cart", "purchase", "view", "click", "filter_clicked", "followup_query"
      - `id` string, uuid, required — The unique identifier for the event
      - `is_conversion` boolean, nullable — Whether the event is a conversion event.
      - `items` string[], required — The items associated with the event. This could be a list of stringified json chunks for search events, or a list of items for add_to_cart, purchase, view, and click events.
      - `metadata` unknown
      - `request_id` string, nullable — The unique identifier for the request the event is associated with.
      - `request_type` string, nullable — The type of request the event is associated with.
      - `updated_at` string, required — The time the event was last updated.
      - `user_id` string, nullable — The user identifier associated with the event.
  - ChatRevenueResponse
    - `points` FloatTimePoint[], required
      - `point` number, double, required
      - `time_stamp` string, required
    - `revenue` number, double, required
  - PopularChatsResponse
    - `chats` PopularChat[], required
      - `count` integer, required
      - `name` string, required

## Other responses

- `400` — Service error relating to getting RAG analytics

---

[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)
