Pagination
All list endpoints return paginated results. Use page and limit query parameters.
Parameters
| Parameter | Type | Description |
|---|---|---|
page | number | Page number, starting from 1 (default: 1) |
limit | number | Items per page (default: 20, max: 100) |
Response Format
Paginated Response
{
"data": [ ... ],
"total": 156,
"page": 2,
"limit": 20
}| Parameter | Type | Description |
|---|---|---|
data | array | Array of items for the current page |
total | number | Total number of items matching the query |
page | number | Current page number |
limit | number | Items per page |
Example: Fetching All Pages
Node.js
async function fetchAllInvoices(apiKey) {
let page = 1;
let allInvoices = [];
while (true) {
const res = await fetch(
`https://api.syncbooksapp.com/api/v1/invoices?page=${page}&limit=100`,
{ headers: { Authorization: `Bearer ${apiKey}` } }
);
const { data, total } = await res.json();
allInvoices.push(...data);
if (allInvoices.length >= total) break;
page++;
}
return allInvoices; // All invoices
}