Pagination

Offset pagination, handled for you.

Four endpoints return paginated collections:

MethodReturns
workspace.listPagesPage
workspace.changesChangeEvent
workspace.listConnectionsConnection
captures.listSourcesIngestSource

All four use offset pagination: limit sets the page size, offset counts items skipped (not pages). Responses carry items, total, limit, and offset.

Let the SDK do it

Both SDKs return an iterator that fetches subsequent pages as you consume it, so the common case needs no pagination code at all:

1// Fetches more pages transparently as the loop advances
2for await (const page of await client.workspace.listPages({ brainId })) {
3 console.log(page.title);
4}

Page at a time

When you’re rendering a paged UI, step explicitly:

1let response = await client.workspace.listPages({ brainId, limit: 25 });
2
3while (true) {
4 for (const page of response.data) render(page);
5 if (!response.hasNextPage()) break;
6 response = await response.getNextPage();
7}

Raw offsets

You can always drive it yourself:

1const first = await client.workspace.listPages({ brainId, limit: 50, offset: 0 });
2const second = await client.workspace.listPages({ brainId, limit: 50, offset: 50 });

Offset pagination isn’t stable under concurrent writes — if pages are created while you iterate, you can see an item twice or skip one. For sync jobs, prefer the change feed with since, which doesn’t have this problem.