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

# Fetch Data

> # Description

Get pivot table data based on measures and dimensions passed through request's body.

# Payload

```json
{
    "projectId": string,
    "fromDate": string,
    "toDate": string,
    "filter": array,
    "dimensions": object,
    "measures": object,
    "groups": array,
    "rows": array,
    "columns": array,
    "conceptAsDimesion": string,
    "batches": array
}
```

where:

* `projectId`: Id of the project to look for. __(Required)__.
* `fromDate`: Starting date to filter responses.
* `toDate`: End date to filter responses.
* `filter`: List of filters to apply to the pivot table data.
* `dimensions`: Ids of questions used for this pivot table
* `measures`: Measure values to show in the pivot table
* `rows`: List of rows to show on the table
* `columns`: List of columns to show on the table
* `conceptAsDimesion`: Id of the concept test used as dimension in the pivot table.

### Measures
Measure values to show in the pivot table

```json
{
    "aggregationType": number,
    "label": string,
    "questionId": string
}
```
Where:

* `aggregationType`: Type of aggregator format for the value. Could be:
  * 1: count
  * 2: min
  * 3: max
  * 4: sum
  * 5: average
* `label`: Name of the aggregation type
* `questionId`: Id of the question selected for this measurement


# Response 

## 200 OK

```json
{
  "matrix": array,
  "chiSquare": object,
}
```
where:

* `matrix`: Matrix containing the values used for the pivot table.
* `chiSquare`

### Chi Square

```json
{
  "pairwiseChiSquare": object,
  "tableChiSquare": object
}
```

Where:

* `pairwiseChiSquare`: Critical value, df and pValue by columns and rows
* `tableChiSquare`: Critical value, df and pValue of the table.

## 401 Unauthorized
> Invalid authorization.

## 404 Not Found
> Resource not found.

## 500 Internal Server Error
> Error occurred in the service.

# Description

Get pivot table data based on measures and dimensions passed through request's body.

# Payload

```json theme={null}
{
    "projectId": string,
    "fromDate": string,
    "toDate": string,
    "filter": array,
    "dimensions": object,
    "measures": object,
    "groups": array,
    "rows": array,
    "columns": array,
    "conceptAsDimesion": string,
    "batches": array
}
```

where:

* `projectId`: Id of the project to look for. **(Required)**.
* `fromDate`: Starting date to filter responses.
* `toDate`: End date to filter responses.
* `filter`: List of filters to apply to the pivot table data.
* `dimensions`: Ids of questions used for this pivot table
* `measures`: Measure values to show in the pivot table
* `rows`: List of rows to show on the table
* `columns`: List of columns to show on the table
* `conceptAsDimesion`: Id of the concept test used as dimension in the pivot table.

### Measures

Measure values to show in the pivot table

```json theme={null}
{
    "aggregationType": number,
    "label": string,
    "questionId": string
}
```

Where:

* `aggregationType`: Type of aggregator format for the value. Could be:
  * 1: count
  * 2: min
  * 3: max
  * 4: sum
  * 5: average
* `label`: Name of the aggregation type
* `questionId`: Id of the question selected for this measurement

# Response

## 200 OK

```json theme={null}
{
  "matrix": array,
  "chiSquare": object,
}
```

where:

* `matrix`: Matrix containing the values used for the pivot table.
* `chiSquare`

### Chi Square

```json theme={null}
{
  "pairwiseChiSquare": object,
  "tableChiSquare": object
}
```

Where:

* `pairwiseChiSquare`: Critical value, df and pValue by columns and rows
* `tableChiSquare`: Critical value, df and pValue of the table.

## 401 Unauthorized

> Invalid authorization.

## 404 Not Found

> Resource not found.

## 500 Internal Server Error

> Error occurred in the service.


## OpenAPI

````yaml POST /v1/pivotTable/fetchData
openapi: 3.0.3
info:
  title: SightX API
  version: 1.0.0
  description: >-
    SightX REST API documentation. Most responses are JSON; some export
    endpoints return files. API access is a paid add-on — contact
    sales@sightx.io for details.
servers:
  - url: https://auth.admin.sightx.io
    description: Authentication (Production)
  - url: https://auth.staging-admin.sightx.io
    description: Authentication (Staging)
security:
  - AuthorizationHeader: []
paths:
  /v1/pivotTable/fetchData:
    post:
      summary: Fetch Data
      description: >-
        # Description


        Get pivot table data based on measures and dimensions passed through
        request's body.


        # Payload


        ```json

        {
            "projectId": string,
            "fromDate": string,
            "toDate": string,
            "filter": array,
            "dimensions": object,
            "measures": object,
            "groups": array,
            "rows": array,
            "columns": array,
            "conceptAsDimesion": string,
            "batches": array
        }

        ```


        where:


        * `projectId`: Id of the project to look for. __(Required)__.

        * `fromDate`: Starting date to filter responses.

        * `toDate`: End date to filter responses.

        * `filter`: List of filters to apply to the pivot table data.

        * `dimensions`: Ids of questions used for this pivot table

        * `measures`: Measure values to show in the pivot table

        * `rows`: List of rows to show on the table

        * `columns`: List of columns to show on the table

        * `conceptAsDimesion`: Id of the concept test used as dimension in the
        pivot table.


        ### Measures

        Measure values to show in the pivot table


        ```json

        {
            "aggregationType": number,
            "label": string,
            "questionId": string
        }

        ```

        Where:


        * `aggregationType`: Type of aggregator format for the value. Could be:
          * 1: count
          * 2: min
          * 3: max
          * 4: sum
          * 5: average
        * `label`: Name of the aggregation type

        * `questionId`: Id of the question selected for this measurement



        # Response 


        ## 200 OK


        ```json

        {
          "matrix": array,
          "chiSquare": object,
        }

        ```

        where:


        * `matrix`: Matrix containing the values used for the pivot table.

        * `chiSquare`


        ### Chi Square


        ```json

        {
          "pairwiseChiSquare": object,
          "tableChiSquare": object
        }

        ```


        Where:


        * `pairwiseChiSquare`: Critical value, df and pValue by columns and rows

        * `tableChiSquare`: Critical value, df and pValue of the table.


        ## 401 Unauthorized

        > Invalid authorization.


        ## 404 Not Found

        > Resource not found.


        ## 500 Internal Server Error

        > Error occurred in the service.
      operationId: fetch-data-post-v1-pivottable-fetchdata
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
            example:
              projectId: '{{projectId}}'
              fromDate: ''
              toDate: ''
              filter: []
              measures:
                '0':
                  aggregationType: 1
                  label: Count
                  questionId: ''
                '1':
                  aggregationType: 1
              dimensions:
                '0': 60e320e3ffcabb005be2af25
                '1': 60e320e3ffcabb005be2af24
              groups:
                60e320e3ffcabb005be2af23:
                  - 60e320e3ffcabb005be2af23
                60e320e3ffcabb005be2af24:
                  - 60e320e3ffcabb005be2af24
                60e320e3ffcabb005be2af25:
                  - 60e320e3ffcabb005be2af25
                60e320e3ffcabb005be2af26:
                  - 60e320e3ffcabb005be2af26
              batches: []
              conceptAsDimesion: ''
              columns:
                - 60e320e3ffcabb005be2af25-1
                - 60e320e3ffcabb005be2af25-2
                - 60e320e3ffcabb005be2af25-3
                - 60e320e3ffcabb005be2af25-4
              rows:
                - 60e320e3ffcabb005be2af24-1
                - 60e320e3ffcabb005be2af24-2
                - 60e320e3ffcabb005be2af24-3
                - 60e320e3ffcabb005be2af24-4
                - 60e320e3ffcabb005be2af24-5
                - 60e320e3ffcabb005be2af24-6
                - 60e320e3ffcabb005be2af24-7
      responses:
        '200':
          description: Fetch Data
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
              example:
                chiSquare:
                  tableChiSquare:
                    pValue: null
                  pairwiseChiSquare:
                    byCols:
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                    byRows:
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                      - - {}
                        - {}
                        - {}
                        - {}
                matrix:
                  - - {}
                    - {}
                    - {}
                    - {}
                  - - {}
                    - {}
                    - {}
                    - {}
                  - - {}
                    - {}
                    - {}
                    - {}
                  - - {}
                    - {}
                    - {}
                    - {}
                  - - {}
                    - {}
                    - {}
                    - {}
                  - - {}
                    - {}
                    - {}
                    - {}
                  - - {}
                    - {}
                    - {}
                    - {}
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '500':
          description: Internal server error
      servers:
        - url: https://pivot-table.sightx.io
components:
  securitySchemes:
    AuthorizationHeader:
      type: apiKey
      in: header
      name: Authorization
      description: Access token obtained from the m2m-token endpoint.

````