> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getlemma.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination

> How to page through large result sets using the Lemma API.

List endpoints return results one page at a time using cursor-based pagination. Each response includes a `data` array for the current page, a `has_next` boolean, and a `cursor` string to fetch the next page.

Cursor pagination is stable: inserting or deleting records between requests will not cause items to be skipped or duplicated.

## Query parameters

All paginated endpoints accept these parameters:

| Parameter | Type    | Default | Maximum | Description                                             |
| --------- | ------- | ------- | ------- | ------------------------------------------------------- |
| `limit`   | integer | `10`    | `100`   | Items per page                                          |
| `cursor`  | string  | —       | —       | Cursor from the previous response. Omit for first page. |

## Response structure

```json theme={null}
{
  "data": [...],
  "has_next": true,
  "cursor": "eyJvcGVuZWRfYXQiOiIyMDI2LTAzLTEyVDE2OjQ1OjAwWiIsImlkIjoiYWNjb3VudF9XcDVtUngzbkt2OGJUaDJkIn0"
}
```

`cursor` is `null` when this is the last page. Pass it as the `cursor` query parameter on the next request to fetch the following page.

## Fetching all pages

To retrieve every item, keep requesting until `has_next` is `false`:

```typescript theme={null}
async function fetchAllTransactions(accountId: string) {
  const results = [];
  let cursor: string | null = null;

  do {
    const params = new URLSearchParams({ account_id: accountId, limit: "100" });
    if (cursor) {
      params.set("cursor", cursor);
    }

    const response = await fetch(
      `https://api.getlemma.com/v0/transactions?${params}`,
      { headers: { Authorization: `Bearer ${API_KEY}` } },
    );
    const page = await response.json();

    results.push(...page.data);
    cursor = page.has_next ? page.cursor : null;
  } while (cursor);

  return results;
}
```
