# Pagination

> Solarium docs. All requests are `POST https://api.trysolarium.com/graphql/` with `Authorization: Bearer <api key>` and a JSON body `{"query": ..., "variables": ...}`. Every query and mutation takes an `organizationId` (find it with `myOrganizations`). Index of all pages: https://trysolarium.com/llms.txt

All list endpoints use **offset-based pagination** with a consistent interface.

### Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `limit` | Int | 25 | Number of items per page (max 200) |
| `offset` | Int | 0 | Number of items to skip |
| `search` | String | — | Case-insensitive text filter (searches relevant fields like name, memo, etc.) |
| `sortBy` | String | — | Field to sort by (e.g. `name`, `currentBalance`, `txnDate`) |
| `sortDir` | String | `asc` | Sort direction: `asc` or `desc` |

### Response shape

Every paginated response includes:
- `items`: the array of results
- `totalCount`: total number of matching records (before pagination)
- `pageSize`: the `limit` that was applied
- `offset`: the `offset` that was applied

To check if there are more pages: `offset + items.length < totalCount`.

Requesting beyond the end of the data returns an empty `items` array, not an error.

## Example

```
# Page 1: first 10 accounts
query {
  listAccounts(
    organizationId: "a1b2c3d4-..."
    limit: 10
    offset: 0
    sortBy: "name"
    sortDir: "asc"
  ) {
    items { id name currentBalance }
    totalCount
    pageSize
    offset
  }
}

# Page 2: next 10
query {
  listAccounts(
    organizationId: "a1b2c3d4-..."
    limit: 10
    offset: 10
    sortBy: "name"
    sortDir: "asc"
  ) {
    items { id name currentBalance }
    totalCount
    pageSize
    offset
  }
}
```

## Example Response

```
# Page 1 response
{
  "data": {
    "listAccounts": {
      "items": [
        { "id": "...", "name": "Accounts Payable", "currentBalance": 4200.00 },
        { "id": "...", "name": "Accounts Receivable", "currentBalance": 12400.00 }
      ],
      "totalCount": 24,
      "pageSize": 10,
      "offset": 0
    }
  }
}

# Last page (fewer items than limit)
{
  "data": {
    "listAccounts": {
      "items": [
        { "id": "...", "name": "Travel", "currentBalance": 890.00 }
      ],
      "totalCount": 24,
      "pageSize": 10,
      "offset": 20
    }
  }
}
```
