Pagination
How paginated results work
When you fetch a collection of resources, you get paginated results. The response contains the record and page counts in the meta
attribute and the URLs of the other pages in the links
attribute.
{
"data": [...],
"meta": {
"record_count": 140,
"page_count": 14
},
"links": {
"first": "https://yourdomain.commercelayer.io/api/skus?page[number]=1&page[size]=10",
"next": "https://yourdomain.commercelayer.io/api/skus?page[number]=2&page[size]=10",
"last": "https://yourdomain.commercelayer.io/api/skus?page[number]=14&page[size]=10"
}
}
If you need to gather information about large sets of resources for analytics/reporting purposes, please avoid making multiple paginated requests to the related resource endpoint. Use exports instead, which are a best fit for that. Alternatively, you can also perform a search query using our Metrics API (at the moment limited to orders, carts, and returns).
Example
The following request fetches the SKUs, setting the page number to 3 and the page size to 5:
curl -g -X GET \
'https://yourdomain.commercelayer.io/api/skus?page[size]=5&page[number]=3' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token'
The example query parameters above use unencoded [
and ]
characters simply for readability. In practice, these characters must be percent-encoded, per the requirements in RFC 3986.
Last updated