Skip to main content
V2 Alpha — This pagination model is part of the V2 API preview. Breaking changes may occur.

Overview

The V2 API uses cursor-based pagination (Relay-style) instead of V1’s offset-based pagination. Cursors provide stable, consistent results even when data is being added or removed between requests.

Pagination Parameters

ParameterTypeDescription
firstinteger (1–100)Number of items to return (forward pagination)
afterstringCursor to start after (forward pagination)
lastinteger (1–100)Number of items to return (backward pagination)
beforestringCursor to start before (backward pagination)
Default page size is 20 items. Maximum is 100.
You cannot combine first with last, or after with before, in the same request.

Response Format

All paginated endpoints return a pageInfo object alongside the data:
{
  "success": true,
  "data": {
    "items": [ ... ],
    "pageInfo": {
      "hasNextPage": true,
      "hasPreviousPage": false,
      "startCursor": "eyJpZCI6IjY1YTFiMmMzZDRlNWY2... ",
      "endCursor": "eyJpZCI6IjY1YTFiMmMzZDRlNWY3..."
    },
    "totalCount": 150
  }
}
FieldTypeDescription
hasNextPagebooleanWhether more items exist after this page
hasPreviousPagebooleanWhether more items exist before this page
startCursorstring | nullCursor of the first item in this page
endCursorstring | nullCursor of the last item in this page
totalCountintegerTotal number of matching items (when available)

Forward Pagination

Fetch the first page, then use endCursor to get the next:
# First page of orders across all vendors
curl "https://api.puppetvendors.com/v2/orders?first=10" \
  -H "x-access-token: YOUR_MERCHANT_TOKEN"

# Next page (use endCursor from previous response)
curl "https://api.puppetvendors.com/v2/orders?first=10&after=eyJpZCI6IjY1YTF..." \
  -H "x-access-token: YOUR_MERCHANT_TOKEN"

Backward Pagination

Use last and before to paginate backwards:
# Last 10 items before a cursor
curl "https://api.puppetvendors.com/v2/orders?last=10&before=eyJpZCI6IjY1YTF..." \
  -H "x-access-token: YOUR_MERCHANT_TOKEN"

Full Iteration Example

let hasMore = true;
let cursor = null;

while (hasMore) {
  const url = cursor
    ? `/v2/orders?first=50&after=${cursor}`
    : '/v2/orders?first=50';

  const response = await fetch(`https://api.puppetvendors.com${url}`, {
    headers: { 'x-access-token': MERCHANT_TOKEN }
  });

  const { data } = await response.json();

  // Process data.orders
  for (const order of data.orders) {
    console.log(order.orderName);
  }

  hasMore = data.pageInfo.hasNextPage;
  cursor = data.pageInfo.endCursor;
}