Guides
Pagination
Every list returns 1 page at a time, with a cursor to the next. Pass it back until it comes back null.
The page shape
Lists take limit (1-100, default 25) and answer with data and next_cursor. Filters such as status or q stay the same from page to page.
{
"data": [
{
"id": "6f1c…",
"title": "Linen overshirt"
},
{
"id": "2b9e…",
"title": "Wool beanie"
}
],
"next_cursor": "MjU"
}Getting the next page
Send next_cursor back as cursor. Treat it as opaque: its format may change. On the last page it is null.
curl "https://3commerce.com/api/v1/products?limit=25&cursor=MjU" \
-H "Authorization: Bearer 3c_live_…"Reading every page
let cursor = null
const products = []
do {
const url = new URL('https://3commerce.com/api/v1/products')
url.searchParams.set('limit', '100')
if (cursor) url.searchParams.set('cursor', cursor)
const response = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.THREECOMMERCE_KEY}` },
})
const page = await response.json()
products.push(...page.data)
cursor = page.next_cursor
} while (cursor)Mind the rate limit on big exports: use limit=100 to make the fewest calls.