> For the complete documentation index, see [llms.txt](https://noiho.gitbook.io/noiho/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://noiho.gitbook.io/noiho/developers/frontend-builders/pagination-and-indexing.md).

# Pagination and indexing

How to scan orders without blowing an RPC response limit.

Order IDs are inclusive and allocated monotonically from zero. Read getMaxOrderId, then scan newest-first in ranges of at most 250 IDs. The non-paginated filtered getters revert once the total order count exceeds MAX\_PAGE\_SIZE, so production integrations must always use the PaginatedInclusive variants.

```ts
const PAGE = 250n
const max = await diamond.read.getMaxOrderId()

for (let end = max; ; ) {
  const start = end >= PAGE - 1n ? end - (PAGE - 1n) : 0n
  const [, orders] = await diamond.read.getOrdersPagedInclusive([start, end])
  await persist(orders)
  if (start === 0n) break
  end = start - 1n
}
```

> **Warning: Do not multicall large order pages**
>
> A single 250-order response can be hundreds of kilobytes. Combining several pages, or duplicate consumers, through Multicall3 can exceed RPC response limits. Use Multicall3 for small independent reads, and issue large order pages individually with in-flight deduplication.

LP discovery uses a different cursor. Call getProviderForAmount(amount, maxFixedToll, maxPercentageToll, 0, limit), then keep going with nextCursor while provider is zero and done is false. limit must be between 1 and 250.

The loop illustrates cursor boundaries, not an unlimited browser load. Apply a request budget, respect Retry-After and expose Load more. Bulk history should run sequentially.
