Recipe

Paginate a partner collection

Walk a partner collection with cursor pagination: pass a limit, follow next_cursor until it is null, and page at a sensible size so you do not exhaust your rate bucket.

2 min read

cursorOpaque token
next_cursorUntil null
StableUnder writes

The loop

let cursor = null;
do {
  const url = `.../applications?limit=100${cursor ? `&cursor=${cursor}` : ''}`;
  const page = await get(url);
  process(page.items);
  cursor = page.next_cursor;
} while (cursor);

Treat next_cursor as opaque and stop when it is null — see the pagination reference.

Page at the right size

Each page is one request against your bucket, so page at a reasonable limit (tens to a hundred) rather than one item at a time. Cursor paging is stable under concurrent inserts, so you can iterate a large, live collection without skipping or repeating rows.

Back off if throttled

If a page returns a 429, apply your back-off and resume from the same cursor — the cursor is stable, so you lose no progress. Persist the cursor if the job may be interrupted.

Frequently asked questions

How do I know when I have reached the end?

When next_cursor is null or absent. Loop while it is present, passing it on the next request, and stop the moment it is null.

Is it safe to paginate a collection that is being written to?

Yes. Cursor pagination is stable under concurrent inserts, so you will not skip or double-read rows mid-iteration — unlike offset/page-number paging.

Funding for UK limited companies

Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.