Skip to main content

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:

ParameterTypeDefaultDescription
pageinteger ≥ 11Requested page (starts at 1).
per_pageinteger 1–10020Number of items per page. Maximum 100.
sort_bystringvaries by resourceField used for sorting. Accepts the same names as the response.
sort_orderasc or descdescSort 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
}
}
FieldDescription
dataArray with the items of the current page.
meta.totalTotal items matching the filters (not just those returned).
meta.pageCurrent page.
meta.per_pageItems per page actually applied.
meta.total_pagesTotal 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=100 minimizes the number of requests and consumes less of the rate limit.
  • Cache meta.total when 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.