Pagination
Environment: Live
Read long lists page by page with a cursor: starting_after, has_more and next_cursor.
# Pagination
Read long lists page by page with a cursor: starting_after, has_more and next_cursor.
## Cursor pagination
List endpoints accept starting_after and return has_more and next_cursor inside data. To read the next page, send data.next_cursor as starting_after. When data.has_more is false you have everything.
Without these parameters a list behaves exactly as it always did. The only change is the two extra fields in data.
| Name | Direction | Meaning |
| --- | --- | --- |
| starting_after | Request | The id of the last row you received. Use the previous response's next_cursor. |
| limit | Request | Rows per page. With starting_after the maximum is 100 (default 100). Without it, each endpoint keeps its existing limit rules. |
| from, to | Request | Optional date filters, UTC: YYYY-MM-DD, YYYY-MM-DD HH:MM:SS or ISO 8601. A date without a time is the start of that day (the end of it for to). |
| data.has_more | Response | true when another page exists. |
| data.next_cursor | Response | The cursor for the next page, or null. |
```nodejs
let cursor = null;
do {
const body = { type: 2, accountnumber: ACCOUNT, limit: 100, ...(cursor ? { starting_after: cursor } : {}) };
const res = await fetch('https://api.moolre.com/open/account/status', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-API-USER': USER, 'X-API-KEY': KEY },
body: JSON.stringify(body),
}).then((r) => r.json());
for (const tx of res.data.transactions) handle(tx);
cursor = res.data.has_more ? res.data.next_cursor : null;
} while (cursor);
```
```python
cursor = None
while True:
body = {"type": 2, "accountnumber": ACCOUNT, "limit": 100}
if cursor:
body["starting_after"] = cursor
res = requests.post("https://api.moolre.com/open/account/status",
headers={"X-API-USER": USER, "X-API-KEY": KEY}, json=body).json()
for tx in res["data"]["transactions"]:
handle(tx)
if not res["data"].get("has_more"):
break
cursor = res["data"]["next_cursor"]
```
## Where it applies
List transactions, Payment ID and bank account transactions, Webhook deliveries, List bulk payouts and List invoices all use the same cursor fields. Cursors are opaque ids: do not build or parse them.
- [List transactions](https://docs.moolre.com/api/accounts/transactions)
- [List bulk payouts](https://docs.moolre.com/api/payouts/bulk/list)
- [List invoices](https://docs.moolre.com/api/invoices/list)
- [Webhook deliveries](https://docs.moolre.com/api/webhooks/deliveries)