# 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
