Learn about how Busha Commerce API endpoints use pagination to efficiently provide listing results.
Overview
Pagination is a strategy that is used to divide a large dataset(records) into smaller bits (pages). All Busha Commerce API endpoints that return a list of datasets support pagination. For example, the List Charges endpoint (Charges API), List Checkouts (Checkouts API) supports pagination.
Each request to these endpoints returns a page of the result set.
For example, suppose your (List Charges) total_entries_size
is 100 entries but the current_entries_size
returned in the response has only 20. This means you received 20 entries for this request. All responses would include a total_pages(int)
object and a page
object that signifies the current page for that response. You include the next page as page
in the URL param for the subsequent request to retrieve the next page .
curl --location 'https://api.commerce.busha.co/charges?page=1&limit=20' \
--header 'X-BC-API-KEY: {SECRET_API_KEY}' \
You can always pass a limit
to the URL query param to restrict the number of entries per page.
The minimum limit is 1 and the maximum is 25. If the limit passed in the request is greater than 25, we'd return 25 as the default.
The Pagination object
Request Arguments
Argument | Description |
---|---|
limit int32 optional | The number of entries you want per page. Default is 25 |
page int32 optional | The page-number you want entries for |
sort string optional | Order of the resources in the response: asc , desc (default) |
Response Attributes
page int32
The current page of the entries in the response
per_page int32
This is the number of entries returned per page. Passing a limit
in the request would update this.
N.B: Default and maximum is 25
offset int32
The number of entries in the previous pages
total_entries_size int32
The total number of entries matching the request regardless of the limit
current_entries_size int32
The total number of entries in the response
total_pages int32
The total number of pages matching the request
{
"status": "",
"message": "",
"pagination": {
"page": 2,
"per_page": 5,
"offset": 5,
"total_entries_size": 26,
"current_entries_size": 5,
"total_pages": 6
},
"data": [
...
]
}