Handling Pagination in Query Results

Many Alexa REST APIs that potentially return many results are paginated. They return a subset, or "page," of results and a paginationContext object with information on how to get the next page of results. This object is in the following general format:

{
   "paginationContext": {
      "nextToken": "{token}"
   },
   "results": [
      {
      ...
      }
   ]
}

The paginationContext object contains the following fields:

Field Description Type Required

nextToken

A token to retrieve additional results. If not present, then there are no more results.

string

No

Limiting page size

To limit page size, add a maxResults query parameter to your request as shown in the following example:

   GET /{resources}?maxResults=10

Requesting the next page of results

You must then send a new GET request to get the next page of results. Your new request should be the same as the previous request, with the addition of a nextToken query parameter set to the nextToken value in the response you received from your previous request.

The response contains results starting from this token and includes the nextToken value only if there are further results.

Request query parameters for limiting page size and requesting the next page of results

Field Description Type Required

maxResults

Maximum number of results to be returned in the response body. Must be greater than zero and less than or equal to 10.

number (integer)

Yes

nextToken

Token to retrieve a specific page of the paginated results. If this token is not present, the response contains the first page of results.

string

No