Paging and keeping a copy

Read long lists a page at a time, and keep your own copy in step by asking only for what changed.

Paging

Lists come a page at a time, 50 by default and up to 200 with limit. When there's more, the reply has a next_cursor. Send it back as cursor to get the next page, until next_cursor is null. A cursor never skips or repeats anything, even when items are added while you're reading.

GET /inventories/{inventory_id}/items?limit=200
GET /inventories/{inventory_id}/items?limit=200&cursor=WyIyMDI2...

Keeping a copy up to date

To keep your system in step without reading everything each time, ask for what changed since you last asked. Items and locations take updated_since, a time. The reply has everything changed at or after it, in the order it changed, and includes deleted ones with deleted_at set, so you learn about deletions too.

  1. The first time, read every page without updated_since.
  2. Keep the newest updated_at you saw.
  3. Next time, read every page with updated_since set to it, and again keep the newest updated_at.

Use our times, not your own clock, so a clock that runs fast can't make you miss a change. Anything changed in the same second as the newest one comes back again, so match items on their id.