> Source: https://developers.terrawallet.us/docs/pagination . Terra Wallet developer docs (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.

> **Preview.** The API is in early access and may change before launch.

## 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": "..."
}
```

- `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

```js
// 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.
