# Pagination

> How to read lists that are longer than one page.

Type: Guide. Updated 2 December 2026. Page: https://www.colossium.cloud/docs/pagination

## The shape of a list

Every list endpoint returns a page and, when there is more, a cursor:

```json
{
  "data": [ { "id": "..." }, { "id": "..." } ],
  "next_cursor": "eyJ0IjoiMjAyNi0xMi0wMlQwOTozMDowMCswMDowMCIsImkiOiIzZjJiOGMxZSJ9"
}
```

`next_cursor` is `null` on the last page. Send it back as `?cursor=` to get the next page, with the same filters. Treat it as an opaque string: do not decode it, build it or store it for long.

## Parameters

| Parameter | Meaning |
| --- | --- |
| `limit` | Items per page, 1 to 100. Default 25. |
| `cursor` | The `next_cursor` of the previous page. |

A `limit` outside 1 to 100, or a cursor that is not one of ours, is `400 invalid_request`.

## Order and stability

Lists are newest first. Pages are cut at a position (the time and id of the last item), not at a count, so a page does not shift when new items arrive, and you never see an item twice or miss one because something was added while you were reading. Items created after you started will not appear in the pages you read after that point; start again to see them.

## Reading everything

Never assume one page is everything. Walk the cursors until `next_cursor` is `null`. The reference clients have this built in (`iterate`).

```javascript
let cursor
const all = []
do {
  const url = new URL("https://api.colossium.cloud/v1/resources")
  url.searchParams.set("limit", "100")
  if (cursor) url.searchParams.set("cursor", cursor)
  const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.COLOSSIUM_API_TOKEN}` } })
  if (!res.ok) throw new Error(String(res.status))
  const page = await res.json()
  all.push(...page.data)
  cursor = page.next_cursor
} while (cursor)
```

```python
import os, requests

items, cursor = [], None
while True:
    params = {"limit": 100, **({"cursor": cursor} if cursor else {})}
    res = requests.get("https://api.colossium.cloud/v1/resources", params=params, timeout=30,
                       headers={"Authorization": f"Bearer {os.environ['COLOSSIUM_API_TOKEN']}"})
    res.raise_for_status()
    page = res.json()
    items += page["data"]
    cursor = page["next_cursor"]
    if not cursor:
        break
```

> **Take only what you need.** Reading everything is rarely necessary. Filter by project, service, state or kind, and keep only the fields you need. A copy of a list in your own system is a copy of data you are now responsible for.
