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

# Pagination

> Page through lists with limit and cursor.

List endpoints return one page at a time:

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

`data` holds the page's items. `nextCursor` is the cursor for the next page, or
`null` on the last page.

## Request the next page

Send `nextCursor` as the `cursor` query parameter, with the same filters as the
first request. You can change `limit` between pages.

```bash theme={null}
curl "https://api.zerogen.com/v1/runs?projectId=5a4b3c2d-1e0f-4a9b-8c7d-6e5f4a3b2c1d&cursor=WzEsIm1aR..." \
  -H "Authorization: Bearer $ZEROGEN_API_KEY"
```

A cursor continues only the list and filters it came from. Sent with other
filters, it fails with `400 validation_failed` and `param` set to `cursor`.
Treat cursors as opaque strings.

| Endpoint | Default `limit` | Largest `limit` |
| - | - | - |
| `GET /v1/models` | 20 | 50 |
| `GET /v1/runs` | 10 | 20 |
| `GET /v1/assets` | 20 | 50 |
| `GET /v1/projects/{projectId}/folders` | 50 | 100 |
| `GET /v1/projects/{projectId}/naming-presets` | 20 | 100 |
| `GET /v1/labels` | 20 | 100 |

`GET /v1/runs` lists newest first, and so does `GET /v1/assets` unless
you send `sort=oldest`.

The Library lists use the same envelope and cursor rules. `GET /v1/skills`
returns up to 100 skills per page and takes no `limit`. `GET /v1/projects`
returns every project in one page, so its `nextCursor` is always `null`.

The following Node.js example reads every page of your runs:

```javascript theme={null}
const API = "https://api.zerogen.com/v1";
const auth = { Authorization: `Bearer ${process.env.ZEROGEN_API_KEY}` };

const runs = [];
let cursor = null;
do {
  const query = new URLSearchParams({ limit: "20" });
  if (cursor) query.set("cursor", cursor);
  const response = await fetch(`${API}/runs?${query}`, { headers: auth });
  const page = await response.json();
  if (!response.ok) throw new Error(`${page.error.code}: ${page.error.message}`);
  runs.push(...page.data);
  cursor = page.nextCursor;
} while (cursor);
```


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