Pagination
Pagination is essential for working with larger data sets, where it is not feasible to fetch all data in a single call.
All top-level API resources, which return a list of items, always return pagination information in the response. Whether pagination on the request is also supported can be found on each endpoint. If you go over the available items with your pagination, the APIs will return empty responses.
The Storefront API offers three ways to perform pagination:
The /v1/products endpoint is limited to a maximum result window of 500,000 items. For that reason and for improved performance, use product-ID-based pagination to extract large product sets.
Page-based Pagination
All endpoints use the page-based pagination by default, if you don't specify otherwise in the request.
| Parameter | Details |
|---|---|
page | The page you want to retrieve items for. |
perPage | How many items you want to retrieve per page. When requesting products, use a
|
| Response Field | Details |
|---|---|
current | The current amount of items returned to you. |
total | The total amount of items which can be retrieved. |
perPage | The
|
page | The |
first | The first page which will always be 1. |
prev | The previous page that you can request. |
next | The next page to be requested. |
last | The last page that you can request. |
Offset-based Pagination
Offset-based pagination allows you to be more flexible with your requests, as the amount of items you retrieve per call can be varied.
The offset parameter should match the number of items retrieved in previous requests. You can adjust the limit parameter as needed while iterating through the data.
| Parameter | Details |
|---|---|
limit | The |
offset | The |
| Response Field | Details |
|---|---|
total | The total number of items for this resource. |
Product-ID-based Pagination
Product-ID-based pagination is only available on the /v1/products endpoint. Use it whenever you want to iterate over large amounts of products, for example for an export or a script that processes all products of a shop.
Instead of requesting pages, you use the product ID of the last item you received as a cursor for the next request. This is far more performant than page-based or offset-based pagination for large data sets, and it is not affected by the maximum result window of 500,000 items the /v1/products endpoint is otherwise limited by.
| Parameter | Details |
|---|---|
minProductId | Only products with an ID greater than or equal to this value are returned. |
perPage | How many items you want to retrieve per page. When requesting products, use a
|
To iterate over all products:
- Start with an initial request using
minProductId=0. - Take the ID of the last product in the response and use that ID + 1 as the
minProductIdof the next request. - Repeat until a request returns an empty list of products. You have now retrieved all available products of the shop.