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

# v2 Crosstab Cell Query

> For any query (JSON object) with audiences and filters in request body it gives back a response with results for specific Crosstab metrics according to the query.



## OpenAPI

````yaml post /v2/query/intersection
openapi: 3.0.0
info:
  title: Audiences Intersection Query
  description: Query for Crosstab Builder.
  version: 2.0.0
servers:
  - url: https://api.globalwebindex.com
security: []
paths:
  /v2/query/intersection:
    post:
      tags:
        - Query
      summary: v2 Crosstab Cell Query
      description: >-
        For any query (JSON object) with audiences and filters in request body
        it gives back a response with results for specific Crosstab metrics
        according to the query.
      operationId: AudienceIntersection
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AudiencesIntersectionQuery'
        description: Crosstab builder query.
        required: true
      responses:
        '200':
          description: Correct results for given query.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AudiencesIntersectionQueryResults'
        '400':
          description: Invalid query in request body.
        '401':
          description: Auth bearer doesn"t have permissions to access this endpoint.
        '403':
          description: >-
            Auth bearer doesn"t have permissions to access some codes in
            requested query.
        '500':
          description: Server is not able to give correct response.
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AudiencesIntersectionQuery:
      type: object
      description: Audiences and filters as parameters for Crosstab Builder metrics.
      title: Query
      required:
        - audiences
      properties:
        audiences:
          type: object
          description: >-
            Object of row and column audiences to make intersection from. If
            only one audience is queried then the base audience is taken as the
            second audience. If none audience is queried then base audience is
            taken for both row and column audiences.
          properties:
            row:
              $ref: '#/components/schemas/AudiencesIntersectionAudience'
            column:
              $ref: '#/components/schemas/AudiencesIntersectionAudience2'
        locations:
          type: array
          description: List of location codes to filter.
          items:
            type: string
          example:
            - s2_1
            - s2_44
        waves:
          type: array
          description: List of wave codes to filter.
          items:
            type: string
          example:
            - q1_2019
            - q2_2019
            - q3_2019
            - q4_2019
        base_audience:
          $ref: '#/components/schemas/BaseAudiencesIntersectionAudience'
    AudiencesIntersectionQueryResults:
      type: object
      description: Result of crosstab builder query.
      title: QueryResults
      required:
        - meta
        - data
      properties:
        meta:
          $ref: '#/components/schemas/AudiencesIntersectionQueryResultsMetadata'
        data:
          $ref: '#/components/schemas/AudiencesIntersectionQueryResultsData'
    AudiencesIntersectionAudience:
      type: object
      description: Wrapper structure containing AudienceExpression.
      title: Audience
      properties:
        id:
          type: string
          example: '133'
        name:
          type: string
          example: my_audience
        expression:
          $ref: '#/components/schemas/AudiencesIntersectionAudienceExpression'
    AudiencesIntersectionAudience2:
      type: object
      description: Wrapper structure containing AudienceExpression.
      title: Audience
      properties:
        id:
          type: string
          example: '134'
        name:
          type: string
          example: my_audience
        expression:
          $ref: '#/components/schemas/AudiencesIntersectionAudienceExpression'
    BaseAudiencesIntersectionAudience:
      type: object
      description: Wrapper structure containing AudienceExpression.
      title: Audience
      properties:
        id:
          type: string
          example: '135'
        name:
          type: string
          example: my_audience
        expression:
          $ref: '#/components/schemas/AudiencesIntersectionAudienceExpression'
    AudiencesIntersectionQueryResultsMetadata:
      type: object
      description: Metadata for crosstab builder query result
      title: AudiencesIntersectionQueryResultsMetadata
      required:
        - type
      properties:
        type:
          type: string
          description: >-
            Query type identifier. (has this one fixed value every time for XB-
            INTERSECTION)
          example: INTERSECTION
    AudiencesIntersectionQueryResultsData:
      type: object
      description: Collection of results of crosstab builder query.
      title: QueryResultsData
      required:
        - audiences
        - base
        - intersect
      properties:
        audiences:
          type: object
          properties:
            row:
              $ref: '#/components/schemas/AudiencesIntersectionQueryAudienceResult'
            column:
              $ref: '#/components/schemas/AudiencesIntersectionQueryAudienceResult'
        base:
          $ref: '#/components/schemas/AudiencesIntersectionQueryBaseResult'
        intersect:
          $ref: '#/components/schemas/AudiencesIntersectionQueryIntersectResult'
    AudiencesIntersectionAudienceExpression:
      type: object
      description: Flexible expression of audience scope.
      title: AudienceExpression
      properties:
        and:
          type: array
          description: List of sub-expressions to apply intersection of their scopes.
          items:
            $ref: '#/components/schemas/AudiencesIntersectionAudienceExpression'
        or:
          type: array
          description: List of sub-expressions to apply union of their scopes.
          items:
            $ref: '#/components/schemas/AudiencesIntersectionAudienceExpression'
        not:
          type: boolean
          description: To use negation of the expression.
        question:
          type: string
          description: Question code to define datapoint scope.
          example: q2
        datapoints:
          type: array
          description: Datapoint codes to limit scopes of interest.
          items:
            type: string
          example:
            - q2_1
            - q2_2
        suffixes:
          type: array
          description: Suffixes to extend datapoint codes for more detailed responses.
          items:
            type: string
          example:
            - '1'
            - '2'
            - '3'
        min_count:
          type: integer
          description: Minimal count of positive datapoints in one response.
          example: 1
      example:
        and:
          - question: q2
            datapoints:
              - q2_1
              - q2_2
            min_count: 1
            not: false
          - question: q6
            datapoints:
              - q6_2
            min_count: 1
            not: false
    AudiencesIntersectionQueryAudienceResult:
      type: object
      description: Metrics of queried audience.
      title: QueryAudienceResult
      required:
        - audience
        - size
        - sample
        - percentage
        - intersect_percentage
      properties:
        audience:
          type: string
          description: Identifier of the audience according to the query.
        size:
          type: integer
          description: >-
            Final weighted universe of audience identified by "audience"
            attribute.
        sample:
          type: integer
          description: >-
            Final count of responses of audience identified by "audience"
            attribute.
        percentage:
          type: number
          description: Ratio between queried audience size and base audience size.
        intersect_percentage:
          type: number
          description: >-
            Ratio between size of intersection of audiences and size of queried
            audience.
    AudiencesIntersectionQueryBaseResult:
      type: object
      description: Metrics of base audience used for intersection
      title: QueryBaseResult
      required:
        - size
        - sample
      properties:
        size:
          type: integer
          description: Final weighted universe of base audience.
        sample:
          type: integer
          description: Final count of responses of base audience.
    AudiencesIntersectionQueryIntersectResult:
      type: object
      description: Metrics of intersection of queried audiences.
      title: QueryIntersectResult
      required:
        - size
        - sample
        - percentage
        - index
      properties:
        size:
          type: integer
          description: Final weighted universe of intersection of queried audiences.
        sample:
          type: integer
          description: Final count of responses of intersection of queried audiences.
        percentage:
          type: number
          description: >-
            Ratio between size of intersection of queried audiences and size of
            base audience.
        index:
          type: number
          description: Likeliness ratio between audiences and intersection.
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: Authorization
      type: apiKey

````