> ## 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 Bulk 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/crosstab
openapi: 3.0.0
info:
  title: Crosstab Query
  description: >-
    Query for Crosstab users. Streams table of audiences intersections aligned
    to rows and columns.
  version: 2.0.0
servers:
  - url: https://api.globalwebindex.com
security: []
paths:
  /v2/query/crosstab:
    post:
      tags:
        - Query
      summary: v2 Crosstab Bulk 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: CrosstabQuery
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CrosstabQuery'
        description: Crosstab query.
        required: true
      responses:
        '200':
          description: Unordered stream of query responses as json objects.
          content:
            application/json-seq:
              schema:
                $ref: '#/components/schemas/CrosstabQueryResult'
        '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:
    CrosstabQuery:
      type: object
      description: Audiences and filters as parameters for Crosstab Builder metrics.
      title: Query
      required:
        - audiences
      properties:
        columns:
          type: array
          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 no audience is queried then base audience is
            taken for both row and column audiences.
          items:
            $ref: '#/components/schemas/CrosstabAudience2'
        rows:
          type: array
          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 no audience is queried then base audience is
            taken for both row and column audiences.
          items:
            $ref: '#/components/schemas/CrosstabAudience'
        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. If not set or empty, will default to
            last 4 accessible waves. This differs from other endpoints where the
            default is all accessible waves because of performance reasons.
          items:
            type: string
          example:
            - q1_2019
            - q2_2019
            - q3_2019
            - q4_2019
        base_audience:
          $ref: '#/components/schemas/BaseCrosstabAudience'
    CrosstabQueryResult:
      type: object
      description: >-
        Result for an intersection of row and column audiences identified by its
        index starting from 0.
      title: QueryResult
      required:
        - audiences
        - base
        - intersect
      properties:
        row:
          $ref: '#/components/schemas/CrosstabAudience'
        row_index:
          type: number
          description: >-
            Index to specific row audience defined by the request. If the value
            is equal to 0, then the audience used was "All base respondents".
        column:
          $ref: '#/components/schemas/CrosstabAudience2'
        column_index:
          type: number
          description: >-
            Index to specific column audience defined by the request. If the
            value is equal to 0, then the audience used was "All base
            respondents".
        audiences:
          type: object
          properties:
            row:
              $ref: '#/components/schemas/CrosstabQueryAudienceResult'
            column:
              $ref: '#/components/schemas/CrosstabQueryAudienceResult'
        base:
          $ref: '#/components/schemas/CrosstabQueryBaseResult'
        intersect:
          $ref: '#/components/schemas/CrosstabQueryIntersectResult'
    CrosstabAudience2:
      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/CrosstabAudienceExpression'
    CrosstabAudience:
      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/CrosstabAudienceExpression'
    BaseCrosstabAudience:
      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/CrosstabAudienceExpression'
    CrosstabQueryAudienceResult:
      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.
    CrosstabQueryBaseResult:
      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.
    CrosstabQueryIntersectResult:
      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.
    CrosstabAudienceExpression:
      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/CrosstabAudienceExpression'
        or:
          type: array
          description: List of sub-expressions to apply union of their scopes.
          items:
            $ref: '#/components/schemas/CrosstabAudienceExpression'
        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
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: Authorization
      type: apiKey

````