Pagination
In this guide, we will look at how to work with paginated responses when querying the Bazoom Client API.
By default, all responses limit results to 10. However, you can adjust this by adding a per_page parameter to your requests (how many results are allowed by page varies by endpoint).
In paginated responses, objects are nested in a data attribute and have pagination information in a meta attribute.
You can navigate the paginated responses by using the page object that includes all the information about the current pagination:
- Name
current_page- Type
- integer
- Description
- The current page of the results.
- Name
per_page- Type
- integer
- Description
- The number of items returned.
- Name
last_page- Type
- integer
- Description
- The last page of the results.
- Name
total- Type
- integer
- Description
- The total number of items across all pages.
Example
In this example, we request the page that starts after the first 100 results in the Marketplace.
- Name
page- Type
- integer
- Description
- The page of the results that you want to retrieve.
- Name
per_page- Type
- integer
- Description
- Limit the number of items returned.
Manual pagination using cURL
curl -G https://api.bazoom.com/client-api/v1/marketplace \
-H "Authorization: Bearer {token}" \
-d page=10 \
-d per_page=10
Paginated response
{
"data": [
//...
],
"meta": {
"current_page": 10,
"from": null,
"last_page": 240,
"per_page": 10,
"total": 2400
}
}