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 offset-based pagination. Cursors provide stable, consistent results even when data is being added or removed between requests.
| Parameter | Type | Description |
|---|
first | integer (1–100) | Number of items to return (forward pagination) |
after | string | Cursor to start after (forward pagination) |
last | integer (1–100) | Number of items to return (backward pagination) |
before | string | Cursor 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.
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
}
}
| Field | Type | Description |
|---|
hasNextPage | boolean | Whether more items exist after this page |
hasPreviousPage | boolean | Whether more items exist before this page |
startCursor | string | null | Cursor of the first item in this page |
endCursor | string | null | Cursor of the last item in this page |
totalCount | integer | Total number of matching items (when available) |
Fetch the first page, then use endCursor to get the next:
# First page of your orders
curl "https://api.puppetvendors.com/v2/vendor/orders?first=10" \
-H "x-access-token: YOUR_VENDOR_TOKEN"
# Next page (use endCursor from previous response)
curl "https://api.puppetvendors.com/v2/vendor/orders?first=10&after=eyJpZCI6IjY1YTF..." \
-H "x-access-token: YOUR_VENDOR_TOKEN"
Use last and before to paginate backwards:
# Last 10 items before a cursor
curl "https://api.puppetvendors.com/v2/vendor/orders?last=10&before=eyJpZCI6IjY1YTF..." \
-H "x-access-token: YOUR_VENDOR_TOKEN"
Full Iteration Example
let hasMore = true;
let cursor = null;
while (hasMore) {
const url = cursor
? `/v2/vendor/orders?first=50&after=${cursor}`
: '/v2/vendor/orders?first=50';
const response = await fetch(`https://api.puppetvendors.com${url}`, {
headers: { 'x-access-token': VENDOR_TOKEN }
});
const { data } = await response.json();
// Process your orders
for (const order of data.orders) {
console.log(order.orderName);
}
hasMore = data.pageInfo.hasNextPage;
cursor = data.pageInfo.endCursor;
}