Listing and Pagination
All GET endpoints that return collections (/v1/customers, /v1/subscriptions, /v1/invoices, etc.) use page-number pagination.
Parameters​
Sent via query string:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer ≥ 1 | 1 | Requested page (starts at 1). |
per_page | integer 1–100 | 20 | Number of items per page. Maximum 100. |
sort_by | string | varies by resource | Field used for sorting. Accepts the same names as the response. |
sort_order | asc or desc | desc | Sort direction. |
Out-of-range values are clamped (e.g.: per_page=999 becomes 100; page=0 becomes 1).
Response​
Every listing follows this envelope:
{
"data": [
{ "id": "per_01HPER", "name": "João Silva", "email": "joao@example.com" }
],
"meta": {
"total": 142,
"page": 1,
"per_page": 20,
"total_pages": 8
}
}
| Field | Description |
|---|---|
data | Array with the items of the current page. |
meta.total | Total items matching the filters (not just those returned). |
meta.page | Current page. |
meta.per_page | Items per page actually applied. |
meta.total_pages | Total number of pages (ceil(total / per_page)). |
The last page may contain fewer than per_page items. When page > total_pages, data comes back empty (it is not an error).
Examples​
First page, default​
curl -H "Authorization: Bearer $KOBANA_TOKEN" \
'https://api.billing.sandbox.kobana.com.br/v1/customers'
Page 3 with 50 items​
curl -H "Authorization: Bearer $KOBANA_TOKEN" \
'https://api.billing.sandbox.kobana.com.br/v1/customers?page=3&per_page=50'
Sorted by name ascending​
curl -H "Authorization: Bearer $KOBANA_TOKEN" \
'https://api.billing.sandbox.kobana.com.br/v1/customers?sort_by=name&sort_order=asc'
Filters + pagination​
Resource-specific filters coexist with page/per_page:
curl -H "Authorization: Bearer $KOBANA_TOKEN" \
'https://api.billing.sandbox.kobana.com.br/v1/customers?search=joao&page=2&per_page=25'
Iterating over all pages​
Recommended pattern in pseudo-code:
async function fetchAll(url, token) {
const out = [];
let page = 1;
while (true) {
const res = await fetch(`${url}?page=${page}&per_page=100`, {
headers: { Authorization: `Bearer ${token}` },
});
const { data, meta } = await res.json();
out.push(...data);
if (page >= meta.total_pages) break;
page += 1;
}
return out;
}
Best practices​
- For incremental synchronization, prefer filtering by
updated_at_gte(or similar available on the endpoint) instead of sweeping all pages. per_page=100minimizes the number of requests and consumes less of the rate limit.- Cache
meta.totalwhen rendering paginators; do not recompute it on every navigation. - Avoid assuming a stable order without an explicit
sort_by— the default order may change between resources.