# Paginate API response

> For the complete documentation index, see [llms.txt](https://developers.thoughtspot.com/docs/llms.txt)

Source: https://developers.thoughtspot.com/docs/rest-api-pagination

# Paginate API response

When you make REST API calls to some endpoints to query data, the API may return many rows of data in the response. You can paginate the JSON response and retain the order of data across all pages. Given the ability to paginate, you can quickly populate tables and make new REST calls every time you go to the next page of the data on the table. There is significant load time if you want to populate the data table with many rows (greater than 1000).

To paginate results in your API response, add the following parameters to the query:

`pagesize` determines the number of rows to include.

```JSON
 {
    "name": "pagesize",
    "description": "pagesize: The number of rows.",
    "defaultValue": "-1",
    "type": "integer"
 }
```

`offset` determines the starting point.

```JSON
 {
    "name": "offset",
    "description": "Offset: The starting point",
    "defaultValue": "-1",
    "type": "integer"
 }
```

`pageNumber` is an alternate way to determine the offset. You must make a call with `pageNumber = 1` first, and then you can access any page. Calling with `pageNumber != 1` as the initial call will fail. `pageNumber = 0` is not a valid value.

```JSON
{
    "name": "pagenumber",
    "description": "PageNumber: This is an alternate way to set offset. This is 1-based indexing. Offset = (pageNumber - 1) * pageSize.",
    "defaultValue": "-1",
    "type": "integer"
}
```

`FormatType` is the JSON format type.

```JSON
{
    "name": "formattype",
    "description": "FormatType: This sets the JSON format type. Values that are allowed are FULL and COMPACT.",
    "defaultValue": "COMPACT",
    "type": "string"
}
```

`COMPACT` is the default type, and is formatted as follows: `['col1', 'col2'] [1, 'a']`. While `FULL` is formatted like this:

{'col1': 1 'col2': 'a'}

## Example

The following example shows ThoughtSpot data that is being populated in a table:

```JSON
{
    "totalRowCount": 1500,
    "pageSize": 1000,
    "pageNumber": 1,
    "data":
    [
       {
            "key1": "value1",
            "key2": "value2"
        },
        {
            "key1": "value1",
            "key2": "value2"
        }
    ]
}
```