> For the complete documentation index, see [llms.txt](https://docs.pay.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pay.io/api-reference/core-concepts/pagination.md).

# Pagination

In Pay.io APIs pagination functionality is provided with **cursor pagination**.&#x20;

Cursor pagination is a method of paginating through large result sets using **encoded cursors** rather than page numbers. It is more efficient than traditional offset-based pagination, particularly for datasets that are frequently updated or high in volume.

***

### Request Format

The following fields are supported in the **request body:**

| Field    | Type               | Description                                              |
| -------- | ------------------ | -------------------------------------------------------- |
| `after`  | string (optional)  | The Cursor to paginate after (for forward pagination).   |
| `before` | string (optional)  | The Cursor to paginate before (for backward pagination). |
| `first`  | integer (optional) | Number of transactions to return.                        |
| `last`   | integer (optional) | Return the last N transactions (backward pagination).    |

#### Example Request&#x20;

Asking to return the first 10 transactions, after the fifth and before the 20th transaction.&#x20;

{% code overflow="wrap" lineNumbers="true" %}

```json
{
  "after": "5", 
  "before": "20", 
  "first": 10
}
```

{% endcode %}

***

### Response Format

The response is given in a `page_info` object, containing the following parameters:

| Field               | Type              | Description                                   |
| ------------------- | ----------------- | --------------------------------------------- |
| `end_cursor`        | string            | The cursor for the last item in the page.     |
| `has_next_page`     | boolean, required | Indicator, if more results are available.     |
| `has_previous_page` | boolean, required | Indicator, if previous results are available. |
| `start_cursor`      | string            | The cursor for the first item on this page.   |

Use `next_cursor` or `previous_cursor` in subsequent requests to navigate through the dataset.

&#x20;**Example response structure**

{% code lineNumbers="true" %}

```json
  "page_info": {
    "end_cursor": "dxM1QxNDowODoxNXwyMWFmYTc3OS1kMmYzLTQ1NGYtYTI3ZS0xOGUyM2MzZWQzMDA=",
    "has_next_page": false,
    "has_previous_page": false,
    "start_cursor": "dHJhbmY1MTFkYi00YWRlLTQwMWQtYTQ5YS1iMDhlOTJiOWYyM2Y="
  },
  "total_count": 4,
```

{% endcode %}

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pay.io/api-reference/core-concepts/pagination.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
