> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trieve.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Recommendation Analytics

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



## OpenAPI

````yaml post /api/analytics/recommendations
openapi: 3.0.3
info:
  title: Trieve API
  description: >-
    Trieve OpenAPI Specification. This document describes all of the operations
    available through the Trieve API.
  contact:
    name: Trieve Team
    url: https://trieve.ai
    email: developers@trieve.ai
  license:
    name: BSL
    url: https://github.com/devflowinc/trieve/blob/main/LICENSE.txt
  version: 0.13.0
servers:
  - url: https://api.trieve.ai
    description: Production server
  - url: http://localhost:8090
    description: Local development server
security: []
tags:
  - name: Invitation
    description: Invitation endpoint. Exists to invite users to an organization.
  - name: Auth
    description: Authentication endpoint. Serves to register and authenticate users.
  - name: User
    description: User endpoint. Enables you to modify user roles and information.
  - name: Organization
    description: >-
      Organization endpoint. Enables you to modify organization roles and
      information.
  - name: Dataset
    description: >-
      Dataset endpoint. Datasets belong to organizations and hold configuration
      information for both client and server. Datasets contain chunks and chunk
      groups.
  - name: Chunk
    description: >-
      Chunk endpoint. Think of chunks as individual searchable units of
      information. The majority of your integration will likely be with the
      Chunk endpoint.
  - name: Chunk Group
    description: >-
      Chunk groups endpoint. Think of a chunk_group as a bookmark folder within
      the dataset.
  - name: Crawl
    description: Crawl endpoint. Used to create and manage crawls for datasets.
  - name: File
    description: >-
      File endpoint. When files are uploaded, they are stored in S3 and broken
      up into chunks with text extraction from Apache Tika. You can upload files
      of pretty much any type up to 1GB in size. See chunking algorithm details
      at `docs.trieve.ai` for more information on how chunking works. Improved
      default chunking is on our roadmap.
  - name: Events
    description: >-
      Notifications endpoint. Files are uploaded asynchronously and events are
      sent to the user when the upload is complete.
  - name: Topic
    description: >-
      Topic chat endpoint. Think of topics as the storage system for gen-ai chat
      memory. Gen AI messages belong to topics.
  - name: Message
    description: >-
      Message chat endpoint. Messages are units belonging to a topic in the
      context of a chat with a LLM. There are system, user, and assistant
      messages.
  - name: Stripe
    description: >-
      Stripe endpoint. Used for the managed SaaS version of this app. Eventually
      this will become a micro-service. Reach out to the team using contact info
      found at `docs.trieve.ai` for more information.
  - name: Health
    description: Health check endpoint. Used to check if the server is up and running.
  - name: Metrics
    description: Metrics endpoint. Used to get information for monitoring
  - name: Analytics
    description: Analytics endpoint. Used to get information for search and RAG analytics
  - name: Experiment
    description: Experiment endpoint. Used to create and manage experiments
paths:
  /api/analytics/recommendations:
    post:
      tags:
        - Analytics
      summary: Get Recommendation Analytics
      description: >-
        This route allows you to view the recommendation analytics for a
        dataset.
      operationId: get_recommendation_analytics
      parameters:
        - name: TR-Dataset
          in: header
          description: >-
            The dataset id or tracking_id to use for the request. We assume you
            intend to use an id if the value is a valid uuid.
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: JSON request payload to filter the graph
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecommendationAnalytics'
        required: true
      responses:
        '200':
          description: The recommendation analytics for the dataset
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecommendationAnalyticsResponse'
        '400':
          description: Service error relating to getting recommendation analytics
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      security:
        - ApiKey:
            - admin
components:
  schemas:
    RecommendationAnalytics:
      oneOf:
        - type: object
          title: LowConfidenceRecommendations
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            page:
              type: integer
              format: int32
              nullable: true
              minimum: 0
            threshold:
              type: number
              format: float
              nullable: true
            type:
              type: string
              enum:
                - low_confidence_recommendations
        - type: object
          title: RecommendationQueries
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            has_clicks:
              type: boolean
              nullable: true
            page:
              type: integer
              format: int32
              nullable: true
              minimum: 0
            sort_by:
              allOf:
                - $ref: '#/components/schemas/RecommendationSortBy'
              nullable: true
            sort_order:
              allOf:
                - $ref: '#/components/schemas/SortOrder'
              nullable: true
            type:
              type: string
              enum:
                - recommendation_queries
        - type: object
          title: QueryDetails
          required:
            - request_id
            - type
          properties:
            request_id:
              type: string
              format: uuid
            type:
              type: string
              enum:
                - query_details
        - type: object
          title: RecommendationUsageGraph
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            granularity:
              allOf:
                - $ref: '#/components/schemas/Granularity'
              nullable: true
            type:
              type: string
              enum:
                - recommendation_usage_graph
        - type: object
          title: RecommendationsPerUser
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            granularity:
              allOf:
                - $ref: '#/components/schemas/Granularity'
              nullable: true
            type:
              type: string
              enum:
                - recommendations_per_user
        - type: object
          title: RecommendationsCTRRate
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            granularity:
              allOf:
                - $ref: '#/components/schemas/Granularity'
              nullable: true
            type:
              type: string
              enum:
                - recommendations_ctr_rate
        - type: object
          title: RecommendationConversionRate
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            granularity:
              allOf:
                - $ref: '#/components/schemas/Granularity'
              nullable: true
            type:
              type: string
              enum:
                - recommendation_conversion_rate
        - type: object
          title: EventFunnel
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            type:
              type: string
              enum:
                - event_funnel
      discriminator:
        propertyName: type
    RecommendationAnalyticsResponse:
      oneOf:
        - $ref: '#/components/schemas/RecommendationsEventResponse'
        - $ref: '#/components/schemas/RecommendationsEventResponse'
        - $ref: '#/components/schemas/RecommendationEvent'
        - $ref: '#/components/schemas/RecommendationUsageGraphResponse'
        - $ref: '#/components/schemas/RecommendationsPerUserResponse'
        - $ref: '#/components/schemas/RecommendationsCTRRateResponse'
        - $ref: '#/components/schemas/RecommendationsConversionRateResponse'
        - $ref: '#/components/schemas/EventNameAndCountsResponse'
    ErrorResponseBody:
      type: object
      required:
        - message
      properties:
        message:
          type: string
      example:
        message: Bad Request
    RecommendationAnalyticsFilter:
      type: object
      properties:
        component_name:
          type: string
          nullable: true
        date_range:
          allOf:
            - $ref: '#/components/schemas/DateRange'
          nullable: true
        recommendation_type:
          allOf:
            - $ref: '#/components/schemas/RecommendationType'
          nullable: true
        top_score:
          allOf:
            - $ref: '#/components/schemas/FloatRange'
          nullable: true
    RecommendationSortBy:
      type: string
      enum:
        - created_at
        - top_score
    SortOrder:
      type: string
      enum:
        - desc
        - asc
    Granularity:
      type: string
      enum:
        - minute
        - second
        - hour
        - day
        - month
    RecommendationsEventResponse:
      type: object
      title: RecommendationsWithClicks
      required:
        - queries
      properties:
        queries:
          type: array
          items:
            $ref: '#/components/schemas/RecommendationEvent'
    RecommendationEvent:
      type: object
      required:
        - id
        - recommendation_type
        - positive_ids
        - negative_ids
        - positive_tracking_ids
        - negative_tracking_ids
        - request_params
        - results
        - top_score
        - dataset_id
        - created_at
        - user_id
      properties:
        created_at:
          type: string
        dataset_id:
          type: string
          format: uuid
        id:
          type: string
          format: uuid
        metadata:
          nullable: true
        negative_ids:
          type: array
          items:
            type: string
            format: uuid
        negative_tracking_ids:
          type: array
          items:
            type: string
        positive_ids:
          type: array
          items:
            type: string
            format: uuid
        positive_tracking_ids:
          type: array
          items:
            type: string
        recommendation_type:
          $ref: '#/components/schemas/ClickhouseRecommendationTypes'
        request_params: {}
        results:
          type: array
          items: {}
        top_score:
          type: number
          format: float
        user_id:
          type: string
    RecommendationUsageGraphResponse:
      type: object
      title: RecommendationUsageGraphResponse
      required:
        - total_requests
        - points
      properties:
        points:
          type: array
          items:
            $ref: '#/components/schemas/IntegerTimePoint'
        total_requests:
          type: integer
          format: int64
          minimum: 0
    RecommendationsPerUserResponse:
      type: object
      required:
        - avg_recommendations_per_user
        - points
      properties:
        avg_recommendations_per_user:
          type: number
          format: double
        points:
          type: array
          items:
            $ref: '#/components/schemas/FloatTimePoint'
    RecommendationsCTRRateResponse:
      type: object
      required:
        - total_ctr
        - points
      properties:
        points:
          type: array
          items:
            $ref: '#/components/schemas/FloatTimePoint'
        total_ctr:
          type: number
          format: double
    RecommendationsConversionRateResponse:
      type: object
      required:
        - conversion_rate
        - points
      properties:
        conversion_rate:
          type: number
          format: double
        points:
          type: array
          items:
            $ref: '#/components/schemas/FloatTimePoint'
    EventNameAndCountsResponse:
      type: object
      required:
        - event_names
      properties:
        event_names:
          type: array
          items:
            $ref: '#/components/schemas/EventNameAndCounts'
    DateRange:
      type: object
      description: >-
        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.
      properties:
        gt:
          type: string
          nullable: true
        gte:
          type: string
          nullable: true
        lt:
          type: string
          nullable: true
        lte:
          type: string
          nullable: true
      example:
        gt: '2021-01-01 00:00:00.000'
        gte: '2021-01-01 00:00:00.000'
        lt: '2021-01-01 00:00:00.000'
        lte: '2021-01-01 00:00:00.000'
    RecommendationType:
      type: string
      enum:
        - Chunk
        - Group
    FloatRange:
      type: object
      properties:
        gt:
          type: number
          format: double
          nullable: true
        gte:
          type: number
          format: double
          nullable: true
        lt:
          type: number
          format: double
          nullable: true
        lte:
          type: number
          format: double
          nullable: true
    ClickhouseRecommendationTypes:
      type: string
      enum:
        - Chunk
        - Group
    IntegerTimePoint:
      type: object
      required:
        - time_stamp
        - point
      properties:
        point:
          type: integer
          format: int64
        time_stamp:
          type: string
    FloatTimePoint:
      type: object
      required:
        - time_stamp
        - point
      properties:
        point:
          type: number
          format: double
        time_stamp:
          type: string
    EventNameAndCounts:
      type: object
      required:
        - event_name
        - event_count
      properties:
        event_count:
          type: integer
          format: int64
        event_name:
          type: string
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

````