Pagination
Navigate through large lists of results with the page and limit parameters.
On this page
Endpoints that return lists are paginated. You choose the page and how many items it contains, and the response tells you whether there are more pages.
Request parameters
| Parameter | In | Description |
|---|---|---|
page |
query | Page number to access. The first page is 1. |
limit |
query | Number of items returned per page. |
Both parameters are required on paginated endpoints, including the filter endpoints that receive the other criteria in the request body.
curl --request GET \
--url 'https://9iq81tsdy4.execute-api.sa-east-1.amazonaws.com/customers/list?page=1&limit=10' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-api-secret: YOUR_API_SECRET' \
--header 'business-id: YOUR_BUSINESS_ID'Response
The items of the page are in docs, next to the pagination details:
{
"statusCode": 200,
"data": {
"docs": [],
"limit": 10,
"currentPage": 1,
"hasNext": true,
"nextPage": 2,
"totalDocs": 21,
"totalPages": 3
}
}| Field | Description |
|---|---|
docs |
Items of the current page. |
limit |
Number of items per page. |
currentPage |
Number of the current page. |
hasNext |
true when there is at least one more page. |
nextPage |
Number of the next page, or null on the last page. |
totalDocs |
Total number of items that match the request. |
totalPages |
Total number of pages. |
In some endpoints the pagination object is nested one level deeper, for example in data.movements, data.paymentLinks or data.pixels. The Responses section of each endpoint shows the exact shape.
Reading every page
Request the next page while hasNext is true:
const baseUrl = 'https://9iq81tsdy4.execute-api.sa-east-1.amazonaws.com';
const headers = {
'x-api-key': process.env.EASYFLOW_API_KEY,
'x-api-secret': process.env.EASYFLOW_API_SECRET,
'business-id': process.env.EASYFLOW_BUSINESS_ID,
};
const customers = [];
let page = 1;
let hasNext = true;
while (hasNext) {
const response = await fetch(`${baseUrl}/customers/list?page=${page}&limit=50`, { headers });
const { data } = await response.json();
customers.push(...data.docs);
hasNext = data.hasNext;
page = data.nextPage;
}Keep limit at a reasonable size, and store the results you already have instead of reading every page on each request.