🚀 VaultsPay API v1 is live. See what's new →
Set UpPagination

Pagination

All list endpoints return page-based pagination metadata alongside the result set.

Response Format

{
  "data": [
    {},
    {}
  ],
  "pagination": {
    "currentPage": 1,
    "perPage": 20,
    "totalPages": 26,
    "totalCount": 506,
    "sort": "id: DESC"
  }
}

Pagination Fields

FieldDescription
currentPageThe current page number (1-indexed)
perPageNumber of records returned per page
totalPagesTotal number of pages available
totalCountTotal number of records across all pages
sortThe sort order applied to the results

To navigate through pages, pass page and perPage as query parameters:

# First page
GET {baseUrl}/resource?page=1&perPage=20
 
# Next page
GET {baseUrl}/resource?page=2&perPage=20

Iterating All Pages

async function fetchAllPages(baseUrl, endpoint, accessToken) {
  const perPage = 20
  let currentPage = 1
  let totalPages = 1
  const allResults = []
 
  do {
    const res = await fetch(`${baseUrl}${endpoint}?page=${currentPage}&perPage=${perPage}`, {
      headers: { Authorization: `Bearer ${accessToken}` }
    })
    const json = await res.json()
 
    allResults.push(...json.data)
    totalPages = json.pagination.totalPages
    currentPage++
  } while (currentPage <= totalPages)
 
  return allResults
}