Pagination

Payluk uses pagination to efficiently return large collections of data. Instead of returning all records at once, paginated endpoints return a subset of results along with metadata that helps you navigate through pages.

Pagination improves performance, reduces response size, and provides a consistent way to fetch large datasets.


Paginated endpoints return a response with two main sections:

- **pagination** – Metadata describing the current page and navigation state
- **data** – The list of records for the current page

### Sample Paginated Response

```json
{
  "status": 200,
  "message": "Customers fetched successfully",
  "data": {
    "pagination": {
      "count": 2,
      "pages": 5,
      "isLastPage": false,
      "nextPage": 2,
      "previousPage": null
    },
    "data": [
      // Array of records for the current page
    ]
  }
}

Pagination Fields Explained

pagination

The pagination object contains metadata about the current result set.

FieldTypeDescription
countnumberNumber of records returned in the current response
pagesnumberTotal number of available pages
isLastPagebooleanIndicates whether the current page is the last page
nextPagenumber | nullThe next page number to request, or null if none
previousPagenumber | nullThe previous page number to request, or null if none

data

The data array contains the actual records returned for the current page.

Each object in the array represents a resource specific to the endpoint (e.g. customers, escrows, transactions).


Navigating Pages

To retrieve the next or previous page:

  • Use the value provided in nextPage or previousPage
  • Pass the page number as a query parameter in your request

Example

GET /customers?page=2

If nextPage is null, there are no more pages available.


Best Practices

  • Always rely on the pagination object instead of guessing page numbers
  • Stop requesting pages when isLastPage is true
  • Handle empty result sets gracefully
  • Avoid requesting very large page sizes to maintain performance

Pagination ensures predictable, efficient, and scalable access to large datasets across Payluk APIs.