# Pagination

> List endpoints in the Anytime Capital Payments API return the newest objects first, a page at a time. Page with limit and the opaque nextCursor.

Source: https://anytime-capital.com/docs/pagination · Markdown: https://anytime-capital.com/docs/pagination.md · All docs: https://anytime-capital.com/docs/llms-full.txt

Every list endpoint (payments, payment links, invoices and customers) returns the newest objects first, a page at a time, in one shape. Pass `limit` (1–100, default 25) and, for the next page, the previous page's `nextCursor` as `cursor`. When `hasMore` is `false` you have everything.

**A page**

```json
{
  "object": "list",
  "data": [
    {
      "object": "payment",
      "id": "pay_7Hq2LmX9cR4tVb",
      "…": "…"
    }
  ],
  "hasMore": true,
  "nextCursor": "pay_7Hq2LmX9cR4tVb"
}
```

| Field | Type | Meaning |
| --- | --- | --- |
| `object` | string | Always `"list"`. |
| `data` | array | This page's objects, newest first. |
| `hasMore` | boolean | Whether there is another page after this one. |
| `nextCursor` | string or null | The id of the last object on this page; pass it as `cursor` to get the next page. Null on the last page. |

## Fetching the next page

```bash
curl "https://anytime-capital.com/api/v1/payments?limit=100&cursor=pay_7Hq2LmX9cR4tVb" \
  -H "Authorization: Bearer $ANYTIME_API_KEY"
```

A cursor is only valid for the list it came from and for your own business. An empty, over-long or unknown cursor answers `400 INVALID_INPUT` with the message `Invalid cursor.`; a `limit` outside 1–100 answers the same code naming `limit`.

## Reading every page

**Node.js 18+**

```javascript
async function* listAll(path, params = {}) {
  let cursor = null;
  do {
    const query = new URLSearchParams({ ...params, limit: "100", ...(cursor ? { cursor } : {}) });
    const res = await fetch(`https://anytime-capital.com/api/v1${path}?${query}`, {
      headers: { Authorization: `Bearer ${process.env.ANYTIME_API_KEY}` },
    });
    const page = await res.json();
    if (!res.ok) throw new Error(`${page.error.code}: ${page.error.message}`);
    yield* page.data;
    cursor = page.hasMore ? page.nextCursor : null;
  } while (cursor);
}

for await (const payment of listAll("/payments", { status: "paid", createdFrom: "2026-10-01" })) {
  console.log(payment.id, payment.amountCents);
}
```

> **Tip:** Each page is one request against your [rate limit](https://anytime-capital.com/docs/rate-limits.md). Use the largest `limit` you need and filter on the server (`status`, `createdFrom`, `createdTo`, `email`, `active`) rather than paging through everything.

---

Anytime Capital is a fintech company, not a bank. Payment processing, banking and payout services are provided by Anytime Capital's licensed partners. Rates shown are for US card payments; international cards, currency conversion and disputes may carry additional fees shown in your dashboard before you accept a payment.
