V2 Preview — 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://staging-api.puppetvendors.com/orders?first=10" \
-H "x-access-token: YOUR_VENDOR_TOKEN"
# Next page (use endCursor from previous response)
curl "https://staging-api.puppetvendors.com/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://staging-api.puppetvendors.com/orders?last=10&before=eyJpZCI6IjY1YTF..." \
-H "x-access-token: YOUR_VENDOR_TOKEN"
Full Iteration Example
const BASE_URL = 'https://staging-api.puppetvendors.com';
let hasMore = true;
let cursor = null;
while (hasMore) {
const params = cursor
? `first=50&after=${cursor}`
: 'first=50';
const response = await fetch(`${BASE_URL}/orders?${params}`, {
headers: { 'x-access-token': VENDOR_TOKEN }
});
const { data } = await response.json();
// Process your orders
for (const order of data.items) {
console.log(order.orderName);
}
hasMore = data.pageInfo.hasNextPage;
cursor = data.pageInfo.endCursor;
}
Python Example
import requests
BASE_URL = "https://staging-api.puppetvendors.com"
headers = {"x-access-token": VENDOR_TOKEN}
cursor = None
while True:
params = {"first": 50}
if cursor:
params["after"] = cursor
resp = requests.get(f"{BASE_URL}/orders", headers=headers, params=params)
data = resp.json()["data"]
for order in data["items"]:
print(order["orderName"])
if not data["pageInfo"]["hasNextPage"]:
break
cursor = data["pageInfo"]["endCursor"]