Pagination
The Crater API employs pagination to efficiently deliver large sets of data, defaulting to 10 items per page to optimize performance and manageability.
Parameters
- Name
page- Type
- number
- Field Type
- Description
The page number to retrieve.
- Name
limit- Type
- number
- Field Type
- Description
The number of items per page.
Pagination Details in Responses
When a list of resources is requested from the API, the response includes:
- A
dataattribute containing an array of the current page's items. - A
metaattribute offering pagination details such as the current page, total number of items, and the total number of pages. - A
linksattribute with URLs to navigate directly to the first, last, previous, and next pages when available.
Pagination Control
To tailor your data retrieval, use the following parameters in your query:
page: Determines the page number of the dataset you wish to access.limit: Sets how many items will be displayed on each page.
Navigating Through Pages
Use the URLs provided in the links attribute for easy navigation:
firstandlastwill take you to the beginning or the end of the list, respectively.prevandnextcan be used to move sequentially through the pages, although in the example above, these arenullsince there is only one page of data.
With these tools, you can effectively manage and access large volumes of data provided by the Crater API.
Manual pagination using cURL
curl --request GET \
"https://payments.your-domain.com/api/v1/invoices" \
--header "Authorization: Bearer {YOUR_AUTH_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Business: 995c98ce-cdd9-4ef6-b018-9c696cb07e9d" \
Example Response
{
"data": [
{
"invoice_number": "INV-000001",
// ...
},
{
"invoice_number": "INV-000002",
// ...
},
{
"invoice_number": "INV-000003",
// ...
}
],
"links": {
"first": "https://payments.your-domain.com/api/v1/invoices?page=1",
"last": "https://payments.your-domain.com/api/v1/invoices?page=2",
"prev": null,
"next": "https://payments.your-domain.com/api/v1/invoices?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "https://payments.your-domain.com/api/v1/invoices?page=1",
"label": "1",
"active": true
},
{
"url": "https://payments.your-domain.com/api/v1/invoices?page=2",
"label": "2",
"active": false
},
{
"url": "https://payments.your-domain.com/api/v1/invoices?page=2",
"label": "Next »",
"active": false
}
],
"path": "https://payments.your-domain.com/api/v1/invoices",
"per_page": 10,
"to": 10,
"total": 30,
"invoice_total_count": 30
}
}