> ## Documentation Index
> Fetch the complete documentation index at: https://developers.e-cross.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination

> Understanding token-based pagination in e-CROSS APIs

e-CROSS APIs use token-based pagination to handle large datasets. This means that instead of returning all results in a single response, the API returns a token that can be used to retrieve the next page of results.

To use pagination, you need to make your first request without the `nextPageToken` query parameter. If the response includes a `nextPageToken` attribute, use it in the `nextPageToken` query parameter for the next request. Repeat until no `nextPageToken` is returned.

Example of how to use pagination:

<CodeGroup>
  ```bash cURL theme={null}
  # First page
  curl -X GET 'https://product.api.e-cross.tech/ext/merchant/skus' \
    -H "Authorization: Bearer ${YOUR_TOKEN}"

  # Next page (using token from previous response)

  curl -X GET "https://product.api.e-cross.tech/ext/merchant/skus?nextPageToken=${TOKEN_FROM_PREVIOUS_RESPONSE}" \
   -H "Authorization: Bearer ${YOUR_TOKEN}"

  ```

  ```javascript Node.js theme={null}
  async function getAllSKUs(token) {
    let allSKUs = [];
    let nextPageToken = null;

    do {
      const url = nextPageToken
        ? `https://product.api.e-cross.tech/ext/merchant/skus?nextPageToken=${nextPageToken}`
        : 'https://product.api.e-cross.tech/ext/merchant/skus';

      const response = await fetch(url, {
        headers: { 'Authorization': `Bearer ${token}` }
      });

      const data = await response.json();
      allSKUs = allSKUs.concat(data.skus);
      nextPageToken = data.nextPageToken;
    } while (nextPageToken);

    return allSKUs;
  }
  ```

  ```python Python theme={null}
  import requests

  def get_all_skus(token):
      all_skus = []
      next_page_token = None

      while True:
          url = 'https://product.api.e-cross.tech/ext/merchant/skus'
          params = {}
          if next_page_token:
              params['nextPageToken'] = next_page_token

          response = requests.get(
              url,
              headers={'Authorization': f'Bearer {token}'},
              params=params
          )

          data = response.json()
          all_skus.extend(data['skus'])

          next_page_token = data.get('nextPageToken')
          if not next_page_token:
              break

      return all_skus
  ```
</CodeGroup>
