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

# Pagination

> Implement pagination for large transaction sets from Yapily's API. Covers cursor-based pagination, configuring page sizes, and handling multi-page transaction retrieval.

## Offset pagination

By default, Yapily limits the maximum amount of transactions returned in one request to [GET Account Transactions](/api-reference/financial-data/get-account-transactions) to 1000. If you request contains more than this limit, you can use pagination access all transactions.

The following fields are used for pagination:

* [`pagination.totalCount`](/api-reference/financial-data/get-account-transactions#response-paging-total-count) - the total number of transactions your query would return
* [`pagination.self.limit`](/api-reference/financial-data/get-account-transactions#parameter-limit) - the value of limit if specified in the request or 1000 if not specified
* [`offset`](/api-reference/financial-data/get-account-transactions#parameter-offset) - the number of transaction records to be skipped

### How it works

1. Send a request to GET Account Transactions. If `pagination.totalCount` is greater than `pagination.self.limit` then you haven't received the full number of transactions for your request.

2. Execute the request again and specify the `offset` property to increment the number by X (where X is the value of `pagination.self.limit`). This will return the next X transactions.

3. Repeat step 2 until `pagination.totalCount` is the same as or less than `pagination.self.limit`.

### Examples

#### No limit specified

For a call to [Get Account Transactions](/api-reference/financial-data/get-account-transactions) that had 6500 transactions without any limit, calling:

* `GET /accounts/{accountId}/transactions` returns transactions 1-1000
* `GET /accounts/{accountId}/transactions?offset=1000` returns transactions 1001-2000
* `GET /accounts/{accountId}/transactions?offset=6000` returns transactions 6001-6500

#### Specifying a limit

For a call to [Get Account Transactions](/api-reference/financial-data/get-account-transactions) that had 467 transactions with a limit=50, calling:

* `GET /accounts/{accountId}/transactions?limit=50` returns transactions 1-50
* `GET /accounts/{accountId}/transactions?limit=50&offset=50` returns transactions 51-100
* `GET /accounts/{accountId}/transactions?limit=50&offset=450` returns transactions 451-467

***

## Cursor-based pagination

<Info>
  Cursor-based pagination feature is currently available as a [Private Beta version](/getting-started/glossary#private-beta).
  Please contact your Customer Success Manager if you would like to access it.
</Info>

Yapily's ['Realtime transactions' API endpoint](/api-reference/financial-data/get-real-time-account-transactions) is used to fetch transactions in real-time using cursor-based pagination.

It accepts `from` and `before` as optional query parameters when sending the initial request, and accepts `cursor` as optional query parameter in subsequent requests.

### How it works

Yapily doesn't set a `limit` for the maximum number of transactions returned per page, but an individual `Institution` can set a limit.

The `meta` object in the response includes `count` that represents the number of transactions in that page, but doesn't return a field for the total number of transactions.

The `data` object in the response contains an array of transactions.

The `links` object in the response returns opaque cursor tokens that can be fed into the subsequent request:

* `first` - a cursor or link to the first page
* `prev` - a cursor or link to the previous page
* `self` - a cursor or link to the current page
* `next` - a cursor or link to the next page
* `last` - a cursor or link to the last page

### Examples

* `GET /accounts/{accountId}/real-time/transactions` to fetch transactions in the first page. Returns `self`, `next` and `last` page cursors:

```json theme={null}
"links": {
    "self": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=aaa",
    "next": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=bbb",
    "last": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=zzz"
 }
```

* `GET /accounts/{accountId}/real-time/transactions?cursor=ccc` to fetch transactions in a middle page. Returns `first`, `prev`, `self`, `next` and `last` page cursors:

```json theme={null}
"links": {
    "first": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=aaa",
    "prev": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=bbb",
    "self": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=ccc",
    "next": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=ddd",
    "last": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=zzz"
}
```

* `GET /accounts/{accountId}/real-time/transactions?cursor=zzz` to fetch transactions in the final page. Returns `first`, `prev` and `self` page cursors:

```json theme={null}
"links": {
    "first": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=aaa",
    "prev": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=yyy",
    "self": "https://api.yapily.com/accounts/{accountId}/real-time/transactions?cursor=zzz"
}
```
