Skip to content
Terra WalletDevelopers

Early access. The Terra API and SDKs may change before launch, and the SDK packages are not published yet.

View as Markdown

API basics

Early access

Pagination

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 parameterMeaning
limitHow many items to return, from 1 to 100
starting_afterThe id to continue after: the next_cursor of the previous page

Response#

JSON

{  "data": [ { "id": "..." } ],  "has_more": true,  "next_cursor": "..."}
  • data holds the items.
  • has_more tells you whether another page exists.
  • next_cursor is the id to pass as starting_after for the next page, or null on 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.