Pagination
Most of the API resources have support for bulk retrieval. You can get a collection of products, variants, attribute groups and other resources.
These API methods share a common structure, supporting at least these two parameters: limit
and cursor
.
Parameters
Parameter | Type | Required | Details |
---|---|---|---|
limit | integer | false | The limit parameter specifies the maximum number of results to be returned per page. Each API resource can have a different default value. |
cursor | string | false | A valid cursor for use in pagination. Can be retrieved from the collection response. |
Collection Response Format
Parameter | Type | Required | Details |
---|---|---|---|
limit | array | true | An array containing the requested entities. |
cursor | ? | false | An object containing information for use in pagination. |
Example
Iterate over all products from a specific shop category
If the total product count exceeds the default limit of 100, you can retrieve the next page of results as follows:
let options = {
limit: 5
};
let collection = null;
do {
let response = await client.apis.AttributeGroups.getAttributeGroups(options);
collection = response.body;
collection.entities.forEach(
attributeGroup => console.log(attributeGroup.name)
);
options.cursor = collection.cursor.next;
} while (collection.cursor.next !== null);