# Pagination

> Cursor paging, why there is no page number, and how to walk a full collection safely.

Source: https://www.propexecutor.com/docs/pagination
Whole reference in one file: https://www.propexecutor.com/doc.md

Collections are cursor-paginated. Every list response has the same two keys: `data` and `next_cursor`.

<!-- List response -->
```json
{
  "data": [ /* … */ ],
  "next_cursor": "MjAyNi0wOS0xNFQwOToxMjowNFrOfDNkMjE"
}
```

When `next_cursor` is `null` you have reached the end. That is the only stop signal — there is no total count, and no page numbers.

## Walking a collection

<!-- curl -->
```bash
# first page
curl "https://api.propexecutor.com/v1/accounts?limit=100" \
  -H "Authorization: Bearer $PFX_KEY"

# the next one
curl "https://api.propexecutor.com/v1/accounts?limit=100&cursor=MjAyNi0wOS0xNFQwOToxMjowNFrOfDNkMjE" \
  -H "Authorization: Bearer $PFX_KEY"
```

<!-- Node -->
```javascript
async function allAccounts(key) {
  const out = [];
  let cursor = null;
  do {
    const url = new URL("https://api.propexecutor.com/v1/accounts");
    url.searchParams.set("limit", "200");
    if (cursor) url.searchParams.set("cursor", cursor);

    const res = await fetch(url, {
      headers: { Authorization: `Bearer ${key}` },
    });
    if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);

    const page = await res.json();
    out.push(...page.data);
    cursor = page.next_cursor;
  } while (cursor);
  return out;
}
```

## Parameters

| Field | Type | Description |
| --- | --- | --- |
| `limit` | integer | Rows per page. Default `50`, maximum `200`. A larger value is clamped rather than rejected. |
| `cursor` | string | Opaque. Pass back exactly what `next_cursor` gave you — do not construct, decode or store one long-term. |

## Why there is no page number

- **Nothing repeats or disappears.** The cursor encodes a position, not a count, so an account created while you are paging cannot shift the rows underneath you and make page two repeat a row from page one.
- **Page 400 costs what page 1 costs.** An offset has to walk and discard every row before it. This does not.
