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

# Pagination

> Read lists page by page with a cursor.

Endpoints that return a list return one page at a time:

```json theme={null}
{
  "data": [],
  "nextCursor": "MjAyNi0xMS0wMlQwOToxNTowMC4wMDBafDNmNmMxYTUy"
}
```

| Parameter | Type | Default | Description |
| - | - | - | - |
| `limit` | integer | `50` | Items per page, from `1` to `100`. |
| `cursor` | string | — | The `nextCursor` value of the previous page. |

* Items are sorted by creation time, oldest first. Items with the same creation time are sorted by `id`.
* `nextCursor` is `null` on the last page.
* Treat the cursor as an opaque value. Do not build or change it. A malformed cursor returns `400`.
* Keep the same `limit` on every page of one read.

## Read all pages

```javascript theme={null}
async function readAll(url, token) {
  const items = [];
  let cursor = null;

  do {
    const pageUrl = new URL(url);
    pageUrl.searchParams.set('limit', '100');
    if (cursor) pageUrl.searchParams.set('cursor', cursor);

    const response = await fetch(pageUrl, {
      headers: { Authorization: `Bearer ${token}` },
    });
    if (!response.ok) throw new Error(`Onio API returned ${response.status}`);

    const page = await response.json();
    items.push(...page.data);
    cursor = page.nextCursor;
  } while (cursor);

  return items;
}

const wishlists = await readAll('https://web.onio.app/api/v1/wishlists', process.env.ONIO_TOKEN);
```


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