Pagination
Cursors and limits
Endpoints that list things, such as keys, goals, webhooks or deliveries, return one page at a time. You ask for up to 200 rows, and the answer holds a cursor that points at the next page. Pass it back until there is none.
A page
Every list answers with data and, when more rows follow, next_cursor:
1{2"data": [3{ "id": "gol_01JD8Q3W6ZK4M2N7P9R5T1V3X8", "name": "Signed up" },4{ "id": "gol_01JD8Q5B2C4E6G8J0L2N4P6R8T", "name": "Started trial" }5],6"next_cursor": "MjAyNi0xMS0xOVQxMDozMDowMFp8Z29sXzAxSkQ4UTVCMkM0RTZHOEowTDJONFA2UjhU"7}
When next_cursor is missing, you have the last page. An empty list is { "data": [] }, never null.
Parameters
400 invalid_limit.next_cursor of the previous page. Leave it out for the first page. A cursor the API didn't give you is 400 invalid_cursor.1curl "https://us.api.vk.viabio.me/v1/projects/prj_…/goals?limit=200&cursor=MjAyNi0x…" \2-H "Authorization: Bearer sk_live_us_…"
Treat the cursor as an opaque string: don't build one, change one or store one for later. Keep the same limit and other parameters while you walk one list.
Order
Rows come in a fixed order, by the time they were made and then by id, so a page never repeats a row or skips one, even when rows are added while you walk the list. Most lists are oldest first; a few, such as a webhook's deliveries, are newest first. The reference says which for each list.
Walk every page
1const base = "https://us.api.vk.viabio.me";2const headers = { Authorization: `Bearer ${process.env.VIAKITE_SECRET_KEY}` };34async function* listAll(path) {5let cursor;6do {7const url = new URL(path, base);8url.searchParams.set("limit", "200");9if (cursor) url.searchParams.set("cursor", cursor);1011const res = await fetch(url, { headers });12if (!res.ok) throw new Error((await res.json()).error.code);13const page = await res.json();1415yield* page.data;16cursor = page.next_cursor;17} while (cursor);18}1920for await (const goal of listAll("/v1/projects/prj_…/goals")) {21console.log(goal.id, goal.name);22}
1import os2import requests34BASE = "https://us.api.vk.viabio.me"5HEADERS = {"Authorization": f"Bearer {os.environ['VIAKITE_SECRET_KEY']}"}67def list_all(path):8params = {"limit": 200}9while True:10res = requests.get(BASE + path, headers=HEADERS, params=params)11res.raise_for_status()12page = res.json()13yield from page["data"]14cursor = page.get("next_cursor")15if not cursor:16return17params["cursor"] = cursor1819for goal in list_all("/v1/projects/prj_…/goals"):20print(goal["id"], goal["name"])
Reports are not paged
Analytics queries don't use cursors. POST /v1/projects/{project}/analytics/query returns all its rows in one answer: 100 rows by default, up to 10,000 with limit. To get fewer rows, filter or ask for fewer breakdowns; see Querying analytics.
Not built yet
A cursor to read past 10,000 rows of a report is planned and not built. For a breakdown with more values than that, split the date range or add a filter and run several queries.