---
title: "paginate | TypeScript SDK | AEO API"
description: "Read a cursor-based list one page at a time when you need the response headers, request ID or page metadata."
url: "https://aeoapi.dev/docs/sdks/typescript/paginate"
canonical: "https://aeoapi.dev/docs/sdks/typescript/paginate"
last_updated: "2026-11-30"
---

# paginate

Read a cursor-based list one page at a time when you need the response headers, request ID or page metadata.

## Signature

```
paginate<O extends { cursor?: string }>(
  fetchPage: (options: O) => Promise<ApiResponse<unknown>>,
  options: O,
): AsyncGenerator<ApiResponse<unknown>>
```

## Parameters

**`fetchPage`**

A function that accepts your filters and cursor and returns the SDK response for one page. Call a list method that returns meta.next_cursor.

**`options`**

The initial filters and optional cursor. Each subsequent request keeps the same filters.

## Return value

An async generator that yields each full response. It reads body.meta.next_cursor and stops when the cursor is empty or absent.

## Errors

- AeoError if the API repeats a cursor or still has another page after 10,000 pages. Errors from fetchPage also reach the caller.

## TypeScript example

```
import { paginate } from "@aeoapi/aeo-sdk";
import { AeoClient } from "@aeoapi/aeo-sdk";

const apiKey = process.env.AEO_API_KEY;
if (!apiKey) throw new Error("Set AEO_API_KEY on your server.");
const client = new AeoClient(apiKey, { baseUrl: "https://api.aeoapi.dev" });

const fetchBrands = (options: { limit?: number; cursor?: string }) =>
  client.v2GetBrands(options);
for await (const page of paginate(fetchBrands, { limit: 25 })) {
  console.log(page.requestId, page.body);
}
```

See [TypeScript client setup](https://aeoapi.dev/docs/sdks/typescript) for authentication, timeouts and retry settings.
