Pagination

A list method returns a Page. Iterate it with for await to walk every page, or read one page at a time and keep the cursor yourself.

List methods return a Page rather than a plain array. Iterating it with for await walks every page, fetching each one as you reach it:

import { Ellipsis } from '@ellipsis-dev/sdk';

const client = new Ellipsis({
  apiKey: process.env.ELLIPSIS_API_TOKEN!,
});

for await (const session of await client.sessions.list()) {
  console.log(session.id, session.status);
}

Awaiting the method fetches the first page; the for await then walks the rest. Nothing accumulates in memory beyond the current page, so it is safe over a long history.

One page at a time

The page exposes the current page directly, which is what you want when you are paging a UI or storing a cursor between runs:

const page = await client.sessions.list({ limit: 25 });
for (const session of page.items) {
  console.log(session.id);
}

if (page.hasMore) {
  const next = await client.sessions.list({
    limit: 25,
    cursor: page.nextCursor!,
  });
}

items is the current page's array, hasMore says whether another page exists, and nextCursor is the cursor to pass for it, or null at the end. page.response is the raw response envelope, for a field the page itself does not surface.

Which methods paginate

The spec decides: a route paginates when its response carries a next_cursor. Today that is sessions.list, sessions.records, reviews.list, alerts.list, and files.list. Every one of them accepts cursor and limit.

Methods that do not paginate return their response object directly. sessions.search is one of them: it returns ranked matches, not a cursored feed.

Collecting a page into an array

There is no helper for this, because the honest version is one line and makes the cost visible:

const sessions = [];
for await (const session of await client.sessions.list()) {
  sessions.push(session);
}

Prefer bounding the work when you can. limit bounds the page size, not the total, so use a filter or stop iterating once you have what you need.

On this page