Pagination

All list endpoints return paginated results. Use the page and limit query parameters to navigate through results.

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number (1-indexed)
limitnumber50Items per page (max 100)

Response Format

Paginated responses include a pagination object:

{
  "data": [
    "..."
  ],
  "pagination": {
    "total": 142,
    "limit": 50,
    "offset": 0,
    "hasMore": true
  }
}

Example: Fetching All Pages

Node.js SDK
let page = 1;
let allClients = [];

while (true) {
  const { data, pagination } = await glance.clients.list({
    page,
    limit: 100,
  });
  allClients.push(...data);

  if (!pagination.hasMore) break;
  page++;
}
REST API equivalent
JavaScript
async function fetchAll(endpoint) {
  let page = 1;
  let allData = [];

  while (true) {
    const res = await fetch(
      `https://api.glance.co.il${endpoint}?page=${page}&limit=100`,
      { headers: { Authorization: `Bearer ${API_KEY}` } }
    );
    const json = await res.json();
    allData.push(...json.data);

    if (!json.pagination.hasMore) break;
    page++;
  }

  return allData;
}