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

# Pagination

> How list endpoints page through results with a cursor.

Every list endpoint returns the same envelope:

```json theme={null}
{
  "data": [ ... ],
  "has_more": true,
  "next_cursor": "eyJwIjoiMjAyNi0xMS0wNVQwNzozMDowMFoiLCJpIjoiM2QyYTdmMTAifQ"
}
```

| Field | Meaning |
| - | - |
| `data` | This page of results. |
| `has_more` | `true` when there's at least one more page. |
| `next_cursor` | Pass this as `cursor` to get the next page. Left out on the last page. |

## Paging through a list

Ask for the first page without a `cursor`. While `has_more` is `true`, ask again with `cursor` set to the `next_cursor` you were given, and the same filters.

`limit` sets the page size, from 1 to 100. The default is 20.

```javascript Node theme={null}
async function allLiveAutomations() {
  const headers = { Authorization: `Bearer ${process.env.INDM_API_KEY}` };
  const out = [];
  let cursor = null;
  do {
    const params = new URLSearchParams({ status: "live", limit: "100" });
    if (cursor) params.set("cursor", cursor);
    const page = await fetch(`https://api.indm.social/v1/automations?${params}`, { headers })
      .then((r) => r.json());
    out.push(...page.data);
    cursor = page.has_more ? page.next_cursor : null;
  } while (cursor);
  return out;
}
```

```python Python theme={null}
import os
import requests

def all_live_automations():
    headers = {"Authorization": f"Bearer {os.environ['INDM_API_KEY']}"}
    out, cursor = [], None
    while True:
        params = {"status": "live", "limit": 100}
        if cursor:
            params["cursor"] = cursor
        page = requests.get(
            "https://api.indm.social/v1/automations", params=params, headers=headers
        ).json()
        out.extend(page["data"])
        if not page["has_more"]:
            return out
        cursor = page["next_cursor"]
```

## Which lists page

| Endpoint | Order | Pages |
| - | - | - |
| [List media](https://docs.indm.social/api-reference/media/list-media.md) | Newest post first | Yes |
| [List automations](https://docs.indm.social/api-reference/automations/list-automations.md) | Newest automation first | Yes |
| [List accounts](https://docs.indm.social/api-reference/accounts/list-accounts.md) | Oldest connection first | Every account in one page; `has_more` is always `false` |

## Cursors

* **Cursors are opaque.** Pass them back exactly as you got them. Their contents may change without notice.
* **A cursor belongs to its list.** Use it with the same endpoint and the same filters. Anything else returns [`cursor_invalid`](https://docs.indm.social/errors#cursor_invalid).
* **Pages hold steady while you read them.** Each cursor marks a position in the list, so a post published while you page lands at the top, not in the middle of your next page, and nothing is skipped or repeated.


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