Powered By GitBook
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.
1
{
2
"data": [...],
3
"meta": {
4
"record_count": 140,
5
"page_count": 14
6
},
7
"links": {
8
"first": "https://yourdomain.commercelayer.io/api/skus?page[number]=1&page[size]=10",
9
"next": "https://yourdomain.commercelayer.io/api/skus?page[number]=2&page[size]=10",
10
"last": "https://yourdomain.commercelayer.io/api/skus?page[number]=14&page[size]=10"
11
}
12
}
Copied!
The default page number is 1 (consequently, the link to the prev page is missing), and the default page size is 10. The maximum page size allowed is 25, but we recommend using a lower value unless strictly necessary.
If you need to modify these default settings, use the page query parameter in your request.

Example

Request
Response
The following request fetches the SKUs, setting the page number to 3 and the page size to 5:
1
curl -X GET \
2
https://yourdomain.commercelayer.io/api/skus?page[size]=5&page[number]=3 \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token'
Copied!
On success, the API responds with a 200 OK status code, returning the five resource objects listed on the third page (from the 6th object to the 10th), together with the record and page counts and the links to the first, prev, next, and last page.
1
{
2
"data": [
3
{
4
"id": "xYZkjABcde",
5
"type": "skus",
6
"links": {...},
7
"attributes": {...},
8
"relationships": {...},
9
"meta": {...}
10
},
11
{
12
"id": "yzkWXfgHQS",
13
"type": "skus",
14
"links": {...},
15
"attributes": {...},
16
"relationships": {...},
17
"meta": {...}
18
},
19
{
20
"id": "aBmNkPQRst",
21
"type": "skus",
22
"links": {...},
23
"attributes": {...},
24
"relationships": {...},
25
"meta": {...}
26
},
27
{
28
"id": "WAspXYhfCV",
29
"type": "skus",
30
"links": {...},
31
"attributes": {...},
32
"relationships": {...},
33
"meta": {...}
34
},
35
{
36
"id": "QWERtyUpBa",
37
"type": "skus",
38
"links": {...},
39
"attributes": {...},
40
"relationships": {...},
41
"meta": {...}
42
}
43
],
44
"meta": {
45
"record_count": 140,
46
"page_count": 28
47
},
48
"links": {
49
"first": "https://yourdomain.commercelayer.io/api/skus?page[number]=1&page[size]=5",
50
"prev": "https://yourdomain.commercelayer.io/api/skus?page[number]=2&page[size]=5",
51
"next": "https://yourdomain.commercelayer.io/api/skus?page[number]=4&page[size]=5",
52
"last": "https://yourdomain.commercelayer.io/api/skus?page[number]=28&page[size]=5"
53
}
54
}
Copied!
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 modified 6mo ago
Copy link
Contents
Example