Pagination
Dievio uses page-based pagination with _page and _per_page.
Request fields
_page: page number (default 1)_per_page: number of rows per page (default 25)max_results: cap on total returned rows (default 500, max 100000)
Keep _per_page, max_results, and the search filters fixed while following next_page. A final page may contain fewer records than _per_page because fewer matches remain or the search reaches max_results.
If the available API credits cannot cover the records to be returned on a page, the API returns HTTP 402 without charging for that page. Top up and retry the same _page with the same request fields.
For network retries, use a separate Idempotency-Key per page. Keep that key when retrying the same page.
Response fields
pageper_page: the fixed page size used for offsets. Readcountfor the number of records actually returned.total_pagestotal_counthas_morenext_page(null whenhas_moreis false)
Example loop
let page = 1;
let results = [];
while (true) {
const res = await fetch('https://dievio.com/api/public/search', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.DIEVIO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ _page: page, _per_page: 100, max_results: 1000 }),
});
if (res.status === 402) throw new Error(`Top up API credits and retry page ${page}.`);
if (!res.ok) throw new Error(`Search failed with HTTP ${res.status} on page ${page}.`);
const data = await res.json();
results = results.concat(data.preview_data || []);
if (!data.has_more) break;
page = data.next_page;
}