Core concepts
Pagination
Cursor-based paging over list endpoints.
List endpoints return up to limit items (default 20, max 100) plus a next_cursor. Pass it back as cursor to fetch the next page; a null cursor means you've reached the end.
paginate.ts
let cursor: string | undefined;
do {
const page = await mail.messages.list({ limit: 100, cursor });
for (const m of page.data) process(m);
cursor = page.nextCursor ?? undefined;
} while (cursor);limitinteger | 1–100. Defaults to 20. |
cursorstring | The next_cursor from the previous page. Omit for the first page. |