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

# Pagination

> Page through DAS API results on OrbitFlare with page numbers, cursors or before/after ranges, and choose sort order and limits.

## Overview

Every DAS list method (`getAssetsByOwner`, `getAssetsByGroup`, `getAssetsByCreator`, `getAssetsByAuthority`, `searchAssets`, `getTokenAccounts`, `getNftEditions` and `getSignaturesForAsset`) returns results in pages. You can page in three ways:

| Method | Parameters | Best for |
| - | - | - |
| Page numbers | `page` | Small result sets and UIs with numbered pages |
| Cursor | `cursor` | Walking a large result set from start to end |
| Range | `before`, `after` | Fetching a slice between two asset IDs |

Use one method per request. Mixing `page` with `cursor`, `before` or `after`, or `cursor` with `before` or `after`, returns `-32602`.

## Limits

* `limit` sets the page size. The maximum and the default are both 1,000.
* `page` starts at 1. `page: 0` is rejected.
* Batch methods (`getAssetBatch`, `getAssetProofBatch`) take at most 1,000 IDs.

## Page numbers

Pass `page` and `limit`. The response echoes `page`:

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getAssetsByGroup",
  "params": {
    "groupKey": "collection",
    "groupValue": "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w",
    "page": 2,
    "limit": 100
  }
}'
```

Stop when a page returns fewer items than `limit`.

<Tip>
  Page numbers are simple, but the database still has to skip every earlier row, so deep pages get slower. For large collections or wallets, use cursors.
</Tip>

## Cursors

When you send no `page`, `before` or `after`, the API pages by cursor and returns a `cursor` value with each page. Pass it back to get the next page:

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
const RPC_URL = 'https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY';

async function getAllAssetsInCollection(collection: string) {
  const assets = [];
  let cursor: string | undefined;

  while (true) {
    const response = await fetch(RPC_URL, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getAssetsByGroup',
        params: {
          groupKey: 'collection',
          groupValue: collection,
          limit: 1000,
          cursor,
        },
      }),
    });
    const { result } = await response.json();

    assets.push(...result.items);
    if (result.items.length < 1000) break;
    cursor = result.cursor;
  }

  return assets;
}
```

Cursors work only when results are sorted by `id`, which is the default.

## Ranges

`before` and `after` take asset IDs and return the assets between them. For example, `after` alone continues from a known asset ID:

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "searchAssets",
  "params": {
    "ownerAddress": "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY",
    "after": "JEGruwYE13mhX2wi2MGrPmeLiVyZtbBptmVy9vG3pXRC",
    "limit": 500
  }
}
```

Ranges also require sorting by `id`.

## Sorting

Methods that list assets accept `sortBy`:

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
"sortBy": {
  "sortBy": "created",
  "sortDirection": "desc"
}
```

<ResponseField name="sortBy.sortBy" type="string">
  `id` (default), `created`, `updated`, `recent_action` or `none`.
</ResponseField>

<ResponseField name="sortBy.sortDirection" type="string">
  `asc` (default) or `desc`.
</ResponseField>

Sorting by anything other than `id` works only with page numbers. Combining it with `cursor`, `before` or `after` returns `-32602`.


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