Skip to Content
ePay.lkDocs

Pagination

List endpoints use cursor pagination — newest first, stable under concurrent writes.

All list endpoints (GET /v1/payments, /v1/refunds, /v1/events) accept:

ParameterDescription
limitPage size, 1–100. Default 20.
cursorOpaque cursor from the previous page's next_cursor. Omit for the first page.

and return:

{
  "object": "list",
  "data": [ { "id": "pay_…" }, { "id": "pay_…" } ],
  "has_more": true,
  "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMlQxMDoxNTowMC4wMDBaIiwiaWQiOiJwYXlf…"
}

Items are ordered newest first by (created_at, id). Because the cursor points at a position (not an offset), new objects created while you page don't cause duplicates or gaps. When has_more is false, next_cursor is null.

Treat cursors as opaque strings — don't build or modify them. A malformed cursor returns 400 invalid_cursor.

Iterate every succeeded payment
async function* allPayments(status = "succeeded") {
  let cursor: string | null = null;
  do {
    const url = new URL("/v1/payments", process.env.EPAY_API_URL);
    url.searchParams.set("status", status);
    url.searchParams.set("limit", "100");
    if (cursor) url.searchParams.set("cursor", cursor);
    const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.EPAY_SECRET_KEY}` } });
    const page = await res.json();
    yield* page.data;
    cursor = page.has_more ? page.next_cursor : null;
  } while (cursor);
}

Filters (such as status or order_id) must stay the same for every page of a listing.