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

# Pagination

> Iterate through paginated collections using cursor-based pagination.

Endpoints that return collections use cursor-based pagination. Each response includes a `pageInfo` object with cursors for navigating forward and backward through results.

## Query parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `limit` | `number` | `100` | Number of items to return per page. Maximum 100. |
| `page` | `string` | - | Cursor for the page to retrieve. Omit to start from the first page. |

## Response format

Paginated responses include `data` (the array of results) and `pageInfo`:

```json theme={null}
{
  "data": [
    { "id": "67a61d5561e4f9de302c02a1", "title": "Summer picks" },
    { "id": "67a61d5561e4f9de302c02a2", "title": "Gift ideas" }
  ],
  "pageInfo": {
    "next": "YWZ0ZXI6NjdhNjFkNTU2MWU0ZjlkZTMwMmMwMmEx",
    "previous": null,
    "totalCount": 42
  }
}
```

| Field | Type | Description |
| - | - | - |
| `next` | `string \| null` | Cursor for the next page. `null` when on the last page. |
| `previous` | `string \| null` | Cursor for the previous page. `null` on the first page. |
| `totalCount` | `number` | Total number of items across all pages. |

## Fetching pages

To load the first page, call a list endpoint with just a `limit`. To load the next page, pass the `next` cursor from the previous response as the `page` parameter.

```typescript @swishapp/api-client theme={null}
import { createApiClient } from "@swishapp/api-client/2026-07";

const client = createApiClient({
  authToken: "your-api-token",
});

// First page
const first = await client.items.list({ limit: 20 });

// Next page (when the user requests more)
if (first.pageInfo?.next) {
  const second = await client.items.list({
    limit: 20,
    page: first.pageInfo.next,
  });
}
```

```typescript JavaScript theme={null}
const baseUrl = "https://swish.app/api/2026-07";
const headers = { Authorization: "Bearer your-api-token" };

// First page
const first = await fetch(`${baseUrl}/items?limit=20`, { headers });
const { data, pageInfo } = await first.json();

// Next page (when the user requests more)
if (pageInfo.next) {
  const second = await fetch(
    `${baseUrl}/items?limit=20&page=${pageInfo.next}`,
    { headers }
  );
}
```

```bash cURL theme={null}
# First page
curl "https://swish.app/api/2026-07/items?limit=20" \
  -H "Authorization: Bearer your-api-token"

# Next page (use the `next` cursor from the previous response)
curl "https://swish.app/api/2026-07/items?limit=20&page=YWZ0ZXI6NjdhNjFkNTU2MWU0ZjlkZTMwMmMwMmEx" \
  -H "Authorization: Bearer your-api-token"
```

When `pageInfo.next` is `null`, you are on the last page.

> [!NOTE]
>
> Cursors are opaque strings. Do not parse, modify, or store them long-term --
> they may change format between API versions.

## Sorting

Some endpoints accept a `sort` parameter that controls the order of results. The available sort options are documented on each endpoint page. Pagination cursors are tied to the sort order used when they were created - do not mix cursors from different sort orders.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.