Pagination

Every list endpoint speaks one pagination contract. You may page with limit / offset or with page / pageSize — both are accepted everywhere, and every list answers with the same pagination block.

Query Parameters

ParameterTypeDefaultDescription
limitnumber50Page size. Clamped to 1–200.
offsetnumber0Row offset to start from.
pagenumber11-based page number. Converted to an offset.
pageSizenumber50Alias of limit.

When both spellings are sent, pageSize wins over limit, and an explicit offset wins over page — the unambiguous value is the one that is honoured. A size above 200 is clamped to 200 rather than rejected.

Response Format

The rows are in data and the window is described in pagination, in both dialects:

{
  "data": [
    "..."
  ],
  "pagination": {
    "total": 500,
    "limit": 50,
    "offset": 0,
    "hasMore": true,
    "page": 1,
    "pageSize": 50,
    "totalPages": 10
  }
}
Legacy keys are still there. Each list also keeps the keys it has always returned — products and totalCount on /products, documents, total, page and pageSize on /documents. Same rows, two spellings; nothing was removed.

Lists That Do Not Paginate

Not every list takes a window. These return the whole set and ignore limit, offset and page entirely — a request for page 2 silently serves page 1 again:

  • GET /purchase — narrow it with startDate/endDate or vendorId instead
  • GET /retainers, GET /files, GET /warehouses
  • GET /products/id/:id/serials, GET /custom-fields
  • GET /grow/tokens, GET /grow/providers
  • GET /document-execution-statuses, GET /reports/documents/saved
Two lists report a page-local total. On GET /grow/payments/payment-pages and GET /grow/recurring-payments, pagination.total counts the rows in the page you were handed rather than the rows that exist, and hasMore is derived from that same number. Page those two until a short page comes back rather than trusting the total.

Iterating All Pages

let offset = 0;
const limit = 200;

while (true) {
  const { data, pagination } = await glance.clients.list({ limit, offset });
  process(data);
  if (!pagination.hasMore) break;
  offset += limit;
}
async function* paginate(endpoint, token) {
  let offset = 0;
  const limit = 200;

  while (true) {
    const res = await fetch(
      `https://api.glance.co.il${endpoint}?limit=${limit}&offset=${offset}`,
      { headers: { Authorization: `Bearer ${token}` } },
    );
    const json = await res.json();
    yield* json.data;

    if (!json.pagination.hasMore) break;
    offset += limit;
  }
}
Paging a moving set. Offsets describe positions, not rows: if documents change while you page, an offset-based sweep can repeat or skip them. To follow changes rather than read a snapshot, use the cursor feed described in Incremental Sync.

Last updated