Pagination and sync
Page by page, or only what changed since last time.
Two modes
Page by page
limit and offset: the classic mode, for screens and reports. Each resource's order is fixed and does not change between versions.
Only what changed (incremental)
desde (date or date-time) turns on incremental mode: only records created or changed since then, in change order. The response carries proximoDesde, proximoId and temMais; send the first two back as desde and depoisDe on the next call until temMais is false.
Pagination parameters
| Name | Type | Description |
|---|---|---|
limit | integer | Max items (up to 200). Default 50. |
offset | integer | Offset for pagination. Default 0. |
desde | string | Only what changed from this instant (ISO-8601: 2026-08-27 or 2026-08-27T14:30:00). Turns on incremental mode: the response carries proximoDesde/proximoId/temMais to send back on the next call. |
depoisDe | integer | The proximoId of the previous response, together with proximoDesde in desde. Breaks ties between records saved at the same instant. |
The response envelope
| Name | Type | Description |
|---|---|---|
data | array | The records of the page. |
moeda | string | Account functional currency (ISO 4217) of the amounts. |
limit | integer | The limit applied. |
offset | integer | The offset applied. |
count | integer | How many records came in this page. |
desde | string | Incremental mode only: the cut applied. |
temMais | boolean | There is another page. |
proximoDesde | string | Incremental mode only: send back as desde on the next call. |
proximoId | integer | Incremental mode only: send back as depoisDe on the next call. |
The sync loop
Store proximoDesde and proximoId after each page and start from them on the next run. Records saved at the same instant are neither lost nor repeated, because the cursor is the date + id pair.
Python
import os
import requests
BASE = "https://tenka.app.br/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['TENKA_API_KEY']}"}
desde, depois_de = "2026-10-01", None # the last saved checkpoint
while True:
params = {"desde": desde, "limit": 200}
if depois_de:
params["depoisDe"] = depois_de
page = requests.get(f"{BASE}/clientes", headers=HEADERS, params=params, timeout=30).json()
if "erro" in page:
raise RuntimeError(page["erro"])
for record in page["data"]:
save(record)
if "proximoDesde" in page:
desde, depois_de = page["proximoDesde"], page["proximoId"]
if not page["temMais"]:
break
save_checkpoint(desde, depois_de)JavaScript
const BASE = "https://tenka.app.br/api/v1";
let desde = "2026-10-01", depoisDe = null; // the last saved checkpoint
while (true) {
const url = new URL(BASE + "/clientes");
url.searchParams.set("desde", desde);
url.searchParams.set("limit", 200);
if (depoisDe) url.searchParams.set("depoisDe", depoisDe);
const page = await (await fetch(url, { headers: { Authorization: "Bearer " + TENKA_API_KEY } })).json();
if (page.erro) throw new Error(page.erro);
page.data.forEach(save);
if (page.proximoDesde) { desde = page.proximoDesde; depoisDe = page.proximoId; }
if (!page.temMais) break;
}
saveCheckpoint(desde, depoisDe);