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

# Get entity stats for a single query

> Returns the entities detected for a single query (brand, competitors and others) with visibility, share of voice, ranking and sentiment, ordered by presence; the body filters by date range, models, entity types and tags.



## OpenAPI

````yaml https://api.mentionlab.io/api/docs-json post /api/analytics/queries/{queryId}/entities
openapi: 3.0.0
info:
  title: MentionLab Public API v0.3.4-rc
  description: ''
  version: 0.3.4-rc
  contact: {}
servers:
  - url: https://api.mentionlab.io
security: []
tags: []
paths:
  /api/analytics/queries/{queryId}/entities:
    post:
      tags:
        - Analytics - Queries
      summary: Get entity stats for a single query
      description: >-
        Returns the entities detected for a single query (brand, competitors and
        others) with visibility, share of voice, ranking and sentiment, ordered
        by presence; the body filters by date range, models, entity types and
        tags.
      operationId: QueriesStatsController_getQueryEntities
      parameters:
        - name: queryId
          required: true
          in: path
          description: UUID of the query to retrieve detected entity stats for.
          schema:
            example: 3fa85f64-5717-4562-b3fc-2c963f66afa6
            type: string
        - name: x-project-id
          in: header
          description: Project ID to specify the project context
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryDetailDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryDetailEntitiesResponse'
        '400':
          description: >-
            The request failed validation — the body, query or path parameters
            are malformed or out of range.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
        '401':
          description: The request is missing valid authentication credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
        '403':
          description: >-
            The authenticated principal lacks the required permission, or access
            to the requested organisation/project.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorResponse'
components:
  schemas:
    QueryDetailDto:
      type: object
      properties:
        startDate:
          type: string
          description: Start date (inclusive)
          example: '2025-01-01'
        endDate:
          type: string
          description: End date (exclusive)
          example: '2025-02-01'
        countries:
          description: Filter by country codes
          example:
            - BE
            - FR
          type: array
          items:
            type: string
        languages:
          description: Filter by language codes
          example:
            - en
            - fr
          type: array
          items:
            type: string
        models:
          description: Filter by AI models
          example:
            - gpt-4o
            - claude-3-5-sonnet
          type: array
          items:
            type: string
        queryIds:
          description: Filter by query IDs
          example:
            - 3fa85f64-5717-4562-b3fc-2c963f66afa6
          type: array
          items:
            type: string
        hasSources:
          type: string
          description: >-
            Filter by source presence: "sources" (only with sources),
            "no_sources" (only without), "all" (no filter). Legacy true/false
            values are still accepted.
          enum:
            - all
            - sources
            - no_sources
        hasShopping:
          type: string
          description: >-
            Filter by shopping presence: "shopping" (only with shopping),
            "no_shopping" (only without), "all" (no filter). Legacy true/false
            values are still accepted.
          enum:
            - all
            - shopping
            - no_shopping
        queryTagIds:
          description: Filter by query tag IDs (numeric — bigint column)
          example:
            - '42'
          type: array
          items:
            type: string
        execTagIds:
          description: Filter by execution tag IDs
          example:
            - 3fa85f64-5717-4562-b3fc-2c963f66afa6
          type: array
          items:
            type: string
        queryTagGroupIds:
          description: >-
            Filter by query tag group IDs — matches rows carrying any tag filed
            under a selected group. Combines with queryTagIds per queryTagMode.
          example:
            - 3fa85f64-5717-4562-b3fc-2c963f66afa6
          type: array
          items:
            type: string
        execTagGroupIds:
          description: >-
            Filter by execution tag group IDs — matches rows carrying any tag
            filed under a selected group. Combines with execTagIds per
            execTagMode.
          example:
            - 3fa85f64-5717-4562-b3fc-2c963f66afa6
          type: array
          items:
            type: string
        queryTypes:
          type: array
          description: >-
            Filter by query type. Include "untyped" to also match queries
            without a type. Results from since-deleted queries are excluded when
            this filter is set.
          items:
            type: string
            enum:
              - comparative
              - informative
              - perception
              - untyped
        queryTagMode:
          type: string
          description: >-
            Query tag matching mode: "or" matches ANY tag (default), "and"
            matches ALL tags.
          enum:
            - and
            - or
          default: or
        execTagMode:
          type: string
          description: >-
            Execution tag matching mode: "or" matches ANY tag (default), "and"
            matches ALL tags.
          enum:
            - and
            - or
          default: or
        timezone:
          type: string
          description: >-
            IANA timezone for date bucketing and filtering (e.g.
            "Europe/Brussels"). Defaults to UTC.
          example: Europe/Brussels
          default: UTC
        groupBy:
          type: string
          description: >-
            Row grouping level for entity results. "none" = one row per entity,
            "division" = one row per division (entities not in a division get
            their own row), "group" = one row per top-level group (divisions
            roll up into their group). Defaults to "none".
          enum:
            - none
            - division
            - group
        groupByEntityGroup:
          type: boolean
          description: >-
            Deprecated — use groupBy instead. true is equivalent to
            groupBy="group".
          deprecated: true
          example: false
        showAllEntities:
          type: boolean
          description: >-
            Include entities that have only ever been seen in a single AI
            response. These are mostly one-off extraction noise and are hidden
            by default.
          example: false
        entityTypes:
          type: array
          description: >-
            Filter which entity types to include in results. Accepted values:
            "owned", "primary", "competitor". Defaults to all types when
            omitted.
          example:
            - owned
            - primary
            - competitor
          items:
            type: string
            enum:
              - owned
              - primary
              - competitor
        entityIds:
          description: Entity IDs for brand-scoped metrics. Defaults to project brand.
          example:
            - 3f8a1c2d-5b6e-4a7f-9c0d-1e2f3a4b5c6d
          type: array
          items:
            type: string
    QueryDetailEntitiesResponse:
      type: object
      properties:
        totalResponses:
          type: number
          description: >-
            Total number of AI responses for this query in the filtered scope
            (denominator for visibility).
          example: 42
        entities:
          description: >-
            All detected entities for this query, ordered by presence (how often
            they appear in AI responses) descending.
          type: array
          items:
            $ref: '#/components/schemas/QueryDetailEntityPoint'
      required:
        - totalResponses
        - entities
    ApiErrorResponse:
      type: object
      properties:
        statusCode:
          type: number
          description: HTTP status code of the error.
          example: 400
        message:
          type: string
          description: >-
            Human-readable description of the error. Validation failures return
            an array of per-field validation errors instead of a single string.
          example: Validation failed
        error:
          type: string
          description: Short name of the HTTP error.
          example: Bad Request
      required:
        - statusCode
    QueryDetailEntityPoint:
      type: object
      properties:
        displayKey:
          type: string
          description: >-
            Canonical entity ID. When aliases are merged, all variants resolve
            to this single key.
          example: 550e8400-e29b-41d4-a716-446655440000
        displayName:
          type: string
          description: Human-readable entity name.
          example: Acme Corp
        isOwned:
          type: boolean
          description: >-
            Whether this entity is owned by the project (the project brand or
            its products).
          example: true
        isPrimary:
          type: boolean
          description: Whether this entity is the primary (main) entity for the project.
          example: true
        isCompetitor:
          type: boolean
          description: Whether this entity is a configured competitor of the project.
          example: false
        mentionCount:
          type: number
          description: >-
            Total mention entries for this entity across all responses for this
            query (raw count, before dedup).
          example: 56
        visibility:
          type: number
          description: >-
            Visibility percentage — how often this entity appears in AI
            responses for this query. Formula: (presentIn / totalResponses) ×
            100.
          example: 67
        shareOfVoice:
          type: number
          description: >-
            Share of voice — this entity's portion of all entity mentions for
            this query. Formula: (mentionCount / total entity mentions) × 100.
            Values across all entities sum to 100%.
          example: 32.1
        avgRanking:
          type: number
          description: >-
            Weighted average position rank for this entity in responses for this
            query. Lower values mean the entity appears earlier/higher in AI
            responses. 0 if no position data.
          example: 2.5
        sentimentScore:
          type: number
          description: >-
            Average sentiment score for this entity across all mentions in this
            query. Scale: 0 (most negative) to 100 (most positive).
          example: 72.3
        sentiment:
          description: >-
            Sentiment breakdown counts (positive / neutral / negative) for this
            entity in this query.
          allOf:
            - $ref: '#/components/schemas/QueryDetailEntitySentiment'
      required:
        - displayKey
        - displayName
        - isOwned
        - isPrimary
        - isCompetitor
        - mentionCount
        - visibility
        - shareOfVoice
        - avgRanking
        - sentimentScore
        - sentiment
    QueryDetailEntitySentiment:
      type: object
      properties:
        positive:
          type: number
          description: Count of mentions with positive sentiment (score > 60).
          example: 35
        neutral:
          type: number
          description: Count of mentions with neutral sentiment (score between 40 and 60).
          example: 15
        negative:
          type: number
          description: Count of mentions with negative sentiment (score < 40).
          example: 6
      required:
        - positive
        - neutral
        - negative

````