# Pagination

List endpoints return one page at a time, using cursors.

```http
GET /v1/events?limit=20
```

```json
{
  "data": [ ],
  "meta": {
    "pagination": { "limit": 20, "has_more": true, "next_cursor": "c_eyJ...", "prev_cursor": null }
  }
}
```

## Parameters

| Parameter | Meaning |
|---|---|
| `limit` | Items per page. Default 20, maximum 100. |
| `cursor` | A cursor from `next_cursor` or `prev_cursor`. |
| `starting_after` | An object ID. Returns items after it. |
| `ending_before` | An object ID. Returns items before it. |

New endpoints do not offer offset pagination. Some older endpoints still page by number until they migrate. The [API reference](https://docs.vabu.live/api.md) shows which style each endpoint uses.

## Walk every page

Keep requesting while `has_more` is `true`, passing the previous `next_cursor`.

```ts
let cursor: string | null = null
do {
  const url = new URL('https://api.vabu.live/v1/events')
  url.searchParams.set('limit', '100')
  if (cursor) url.searchParams.set('cursor', cursor)

  const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.VABU_API_KEY}` } })
  const { data, meta } = await res.json()

  for (const item of data) console.log(item.id)
  cursor = meta.pagination.has_more ? meta.pagination.next_cursor : null
} while (cursor)
```

Cursors are opaque. Do not build or edit them.
