Pagination for Amazon SP API
This example demonstrates custom pagination using a nextToken returned in the API response .
API Response

Custom Pagination for Amazon SP API
import base64
response_parameters = "['items']"
nextToken = api_response['pagination']['nextToken']
result1 = nextToken.rstrip("=")
skip_token = result1
Params
{
"pageToken": "{%skip_token%}"
}
Pre-request Script
skip_token = ''
Explanation
api_response→ Refers to the complete JSON response returned by the API.items→ Contains the actual product records.pagination.nextToken→ Token required to fetch the next page of results.
- The script removes trailing
=characters fromnextTokenbefore assigning it toskip_token. - The
pageTokenparameter dynamically uses{%skip_token%}. - The pre-request script initializes
skip_tokenas an empty string for the first API call.