Products
The published catalog, as the shop's own storefront lists it: search, filter and sort products, and read one in full.
Reach them through $storefront->products. A publishable or a secret key reads them.
List products
$storefront->products->list(array $query = []): array
One numbered page of the products the storefront lists, filtered and sorted as its own catalog is. 20 per page by default, at most 50.
taxonomy takes term ids from any classifications, from taxonomies->terms(). Within a classification any chosen term matches, and every classification chosen must match.
Parameters
| Parameter | Type | |
|---|---|---|
$query |
array |
The query fields below, by name. |
Query fields
| Parameter | Type | Description |
|---|---|---|
search | string | At most 200 characters. |
taxonomy[] | array of integer | Term ids from any classifications (from /api/v1/taxonomies/{taxonomy}/terms), at most 20. A product matches when it has any of the chosen terms within each classification, in every classification chosen (brand A or B, and red). At most 20 items. |
minPrice | number | At least 0. |
maxPrice | number | At least 0. |
inStock | boolean | |
featured | boolean | |
sort | string | One of newest, price_asc, price_desc, name_asc, featured. |
page | integer | At least 1. |
perPage | integer | At least 1. At most 50. Default 20. |
locale | string | One of the shop's languages. Else Accept-Language, else the shop's default language. |
Returns
An array with data (a list of ProductSummary), links and meta:
| Field | Type | Description |
|---|---|---|
links | object | |
links.first | string (uri) | |
links.last | string (uri) | |
links.prev | string (uri) or null | |
links.next | string (uri) or null | |
meta | object | |
meta.currentPage | integer | |
meta.from | integer or null | |
meta.lastPage | integer | |
meta.links | array of object | |
meta.links[].url | string (uri) or null | |
meta.links[].label | string | |
meta.links[].page | integer or null | |
meta.links[].active | boolean | |
meta.path | string (uri) | |
meta.perPage | integer | |
meta.to | integer or null | |
meta.total | integer | |
data | array of ProductSummary | |
data[].id | integer | |
data[].slug | string | |
data[].title | string or null | |
data[].sku | string or null | |
data[].price | Money | Fields: amount, currency, formatted. |
data[].regularPrice | Money | Fields: amount, currency, formatted. |
data[].onSale | boolean | |
data[].inStock | boolean | |
data[].rating | Rating or null | |
data[].rating.average | number | |
data[].rating.count | integer | |
data[].image | string (uri) or null |
Errors
| Status | When |
|---|---|
401 | invalid_api_key: no active Storefront key of this shop, or invalid_customer_token: a bearer token not valid for this shop. |
402 | The shop is suspended (message only). |
403 | origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only). |
404 | Not found, or the shop's plan has no Integration API. |
422 | Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid). |
429 | Rate limited. |
Example
$page = $storefront->products->list([
'taxonomy' => [4],
'inStock' => true,
'sort' => 'price_asc',
'page' => 2,
]);
foreach ($page['data'] as $product) {
echo $product['name'], PHP_EOL;
}
Get a product
$storefront->products->get(string $slug): array
One published product in full, by its slug: its description, images, stock, categories, specifications, reviews and variants.
Parameters
| Parameter | Type | |
|---|---|---|
$slug |
string |
The product's slug. |
Returns
A ProductDetail array:
| Field | Type | Description |
|---|---|---|
id | integer | |
slug | string | |
title | string or null | |
sku | string or null | |
price | Money | Fields: amount, currency, formatted. |
regularPrice | Money | Fields: amount, currency, formatted. |
onSale | boolean | |
inStock | boolean | |
rating | Rating or null | |
rating.average | number | |
rating.count | integer | |
image | string (uri) or null | |
description | string or null | Purified HTML. |
shortDescription | string or null | Purified HTML. |
partNumber | string or null | |
unit | string or null | |
stockQuantity | integer or null | Null when the product doesn't track stock. |
images | array of string (uri) | |
categories | array of object | |
categories[].id | integer | |
categories[].slug | string | |
categories[].name | string or null | |
categories[].type | string or null | |
specifications | array of object | |
specifications[].group | string or null | |
specifications[].rows | array of object | |
specifications[].rows[].name | string | |
specifications[].rows[].value | string | |
specifications[].rows[].unit | string or null | |
reviews | object or null | Null when the shop has reviews off. |
reviews.averageRating | number | |
reviews.totalReviews | integer | |
reviews.distribution | object | Review counts by star rating. |
reviews.distribution.5 | integer | |
reviews.distribution.4 | integer | |
reviews.distribution.3 | integer | |
reviews.distribution.2 | integer | |
reviews.distribution.1 | integer | |
variants | array of object | The product's siblings in its variable product group that this storefront sells, this product included. |
variants[].productId | integer | |
variants[].slug | string | |
variants[].isThisProduct | boolean | |
variants[].options | array of object | |
variants[].options[].type | string or null | |
variants[].options[].value | string or null | |
variants[].price | Money | Fields: amount, currency, formatted. |
variants[].inStock | boolean |
Errors
| Status | When |
|---|---|
401 | invalid_api_key: no active Storefront key of this shop, or invalid_customer_token: a bearer token not valid for this shop. |
402 | The shop is suspended (message only). |
403 | origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only). |
404 | product_not_found, or the shop's plan has no Integration API. |
429 | Rate limited. |
Example
$product = $storefront->products->get('ceramic-mug');