Pagination
Learn about how DRUO API endpoints use pagination to efficiently provide listing results.
Pagination is a process that is used to divide a large dataset into smaller chunks (pages). Accounts, Payments and Payouts endpoints support pagination. Each request to these endpoints returns a page of the result set.
When the result is truncated (there are more resources to retrieve), the response also returns a page_info
object containing has_next_page
field with a true value.
For example, suppose your ListPayments
result set is 500 payments but the page returned in the response has only 200. In this case, the response includes a has_next_page=true
. This means that you can send another request for the next page (next set of payments). As long as each call results in a response that includes a has_next_page=true
, you continue to send ListPayment
requests (in each request increase the number of the page). The last page of the result set returns has_next_page=false
.
Page limitations
page
and page_size
fields that the application can use to indicate the page size (the number of items to return in the response). If you do not specify a page_size
, the default limit applies (1000).A page of retrieved records has a limited lifespan. Pages can become stale when other endpoints add, update, or delete records, which changes the set of returned records if a given page is requested again.
Specifying cursor and page sizes
In your initial call to a paginated endpoint, there is no need to include a page
or page_size
: the first page of results is returned (page=1
). Optionally, you can constrain the number of results returned using a page_size
.
The GET requests do not have a body. Therefore, you include a cursor as a query parameter. The following applies when specifying page
and page_size
fields in these endpoint requests:
curl https://api.druo.com/payments/list?page=1&page_size=3 \
-X GET \
-H 'Authorization: Bearer ACCESS_TOKEN'
The sample response includes an object page_info
with has_next_page=true
indicating that there are more payments to retrieve.
{
"payments": [
{
...
},
{
...
},
{
...
}
],
"page_info": {
"has_next_page": true,
"page_size": 10
}
}