> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meetdarwin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination in the TypeScript SDK

> Page through Darwin API lists with @meetdarwin/api: await one page, iterate every item with for await, read whole pages, or collect an array with a ceiling, and sync only what changed.

Every `list` method returns a `PagePromise`. Await it for one page; iterate it with `for await` for every item across all pages.

```ts theme={null}
// One page: { object: "list", data, has_more, next_cursor }
const page = await darwin.contacts.list({ limit: 100 });

// Every contact changed since the last sync, fetching pages as needed.
for await (const contact of darwin.contacts.list({ limit: 100, updated_since: lastSync })) {
  await saveToCrm(contact);
}

// Whole pages, or an array with a ceiling (default 10,000).
for await (const page of darwin.meetings.list().pages()) console.log(page.data.length);
const recent = await darwin.events.list({ type: "meeting.booked" }).toArray({ max: 500 });
```

Nothing is sent until you await or iterate. The filters you pass are repeated on every page. To resume by hand, pass a page's `next_cursor` as `starting_after`.

## Sync only what changed

A sync job should record the time it starts, not the time it ends, and pass that as `updated_since` next run: records that change while you page can move ahead of your cursor.

```ts theme={null}
const started = new Date();
for await (const contact of darwin.contacts.list({ limit: 100, updated_since: state.lastRun })) {
  await crm.upsertPerson(contact);
}
state.lastRun = started; // only after every page succeeded
```

How cursors, ordering and `updated_since` work in the API itself: [Pagination and syncing](https://docs.meetdarwin.ai/api-reference/pagination.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.