Paginating results
Page through a collection with a cursor instead of a page number.
Collections are paged with an opaque cursor. Every page carries nextCursor. Pass it back to get
the next page, and stop when it is null.
curl "https://fabric.inc/api/v1/brands/$BRAND/products?limit=100" \
-H "Authorization: Bearer $FABRIC_API_KEY"{
"data": [{ "id": "prd_...", "sku": "SW-001" }],
"nextCursor": "eyJpZCI6InByZF8..."
}curl "https://fabric.inc/api/v1/brands/$BRAND/products?limit=100&cursor=eyJpZCI6InByZF8..." \
-H "Authorization: Bearer $FABRIC_API_KEY"nextCursor is always present. On the last page it is null, not missing, so a loop only has to
check one condition.
Offset paging is refused
offset, page and skip return 400. They are not ignored.
A catalog can change while you read it. When an import finishes or a product is archived, every later row moves position. Offset paging then skips some rows and returns others twice, and the response gives no sign of it. A cursor points at a row, not a position, so this cannot happen.
Limits
limit defaults to 50, with a maximum of 200. A higher value is refused rather than reduced to
200, because receiving 200 rows after asking for 1,000 looks the same as a catalog with 200
products.
Read the whole catalog
cursor=""
while :; do
page=$(curl -s "https://fabric.inc/api/v1/brands/$BRAND/products?limit=200&cursor=$cursor" \
-H "Authorization: Bearer $FABRIC_API_KEY")
echo "$page" | jq -c '.data[]'
cursor=$(echo "$page" | jq -r '.nextCursor // empty')
[ -z "$cursor" ] && break
doneA cursor stays valid while the catalog changes. It holds a position and nothing else (no filter, brand or permission), so each page is checked against what your credential can read at the time.