API basics
Early accessPagination
List routes return one page at a time and a cursor for the next page. Cursors stay stable while new objects are created, so you never skip or repeat items the way offset pagination can.
Request#
| Query parameter | Meaning |
|---|---|
limit | How many items to return, from 1 to 100 |
starting_after | The id to continue after: the next_cursor of the previous page |
Response#
JSON
{ "data": [ { "id": "..." } ], "has_more": true, "next_cursor": "..."}dataholds the items.has_moretells you whether another page exists.next_cursoris the id to pass asstarting_afterfor the next page, ornullon the last page.
Example: read every audit log entry#
JavaScript
// Preview: page through GET /v1/audit-logs (Node 18 or later).async function* auditLogs() { let cursor = null; do { const url = new URL("https://terrawallet.us/api/v1/audit-logs"); url.searchParams.set("limit", "100"); if (cursor) url.searchParams.set("starting_after", cursor); const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.TERRA_SECRET_KEY}` }, }); if (!res.ok) throw new Error(`Terra API error ${res.status}`); const page = await res.json(); yield* page.data; cursor = page.has_more ? page.next_cursor : null; } while (cursor);} for await (const entry of auditLogs()) console.log(entry.action);The limit has a hard maximum of 100. Ask for fewer when you only need the newest items.