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

# Pagination

> Iterate orders and rebalances without managing cursors

List endpoints return a page of results plus a `nextPageToken` cursor. The
`paginateOrders` and `paginateRebalances` helpers follow that cursor for you and
yield individual items, so you can `for await` over the full history without
handling tokens yourself.

```ts theme={null}
import { createClient, paginateOrders, paginateRebalances } from "@parlayx/sdk";

const client = createClient({ apiKey: process.env.PARLAYX_API_KEY! });

for await (const order of paginateOrders(client, { status: ["open"] })) {
  console.log(order.orderId, order.status);
}

for await (const rebalance of paginateRebalances(client)) {
  console.log(rebalance.rebalanceId, rebalance.status);
}
```

Both helpers accept the same filters as their list endpoint (minus the page
cursor) and stop automatically once the last page is reached. Each request still
throws a [`RequestError`](/sdk/errors) on failure. If you need raw pages or the
`nextPageToken` directly, call `client.listOrders()` and
`client.listRebalances()` instead.
