List all Product Variants
Returns a list of product variants. You can use product permalink:
GET /api/v2/storefront/products/knitted-high-neck-sweater/variants
Or Product ID:
GET /api/v2/storefront/products/21/variants
Note API will attempt a permalink lookup before an ID lookup.
GET
/
api
/
v2
/
storefront
/
products
/
{product_slug}
/
variants
List all Product Variants
const options = {method: 'GET'};
fetch('https://demo.spreecommerce.org/api/v2/storefront/products/{product_slug}/variants', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request GET \
--url https://demo.spreecommerce.org/api/v2/storefront/products/{product_slug}/variants{
"data": [
{
"id": "1",
"type": "variant",
"attributes": {
"sku": "SKU-1001",
"price": "15.99",
"currency": "USD",
"display_price": "$15.99",
"weight": "10",
"height": "10",
"width": "10",
"depth": "10",
"is_master": true,
"options_text": "Size: small, Color: red",
"options": [
{
"name": "<string>",
"value": "<string>",
"presentation": "<string>"
}
],
"purchasable": true,
"in_stock": true,
"backorderable": true
},
"relationships": {
"product": {
"data": {
"id": "<string>",
"type": "<string>"
}
},
"images": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"option_values": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
}
}
}
],
"meta": {
"count": 7,
"total_count": 145,
"total_pages": 10
},
"links": {
"self": "<string>",
"next": "<string>",
"prev": "<string>",
"last": "<string>",
"first": "<string>"
},
"included": [
{
"id": "1",
"type": "product",
"attributes": {
"name": "Example product",
"description": "Example description",
"available_on": "2012-10-17T03:43:57Z",
"slug": "example-product",
"price": "15.99",
"currency": "USD",
"display_price": "$15.99",
"purchasable": true,
"in_stock": true,
"backorderable": true,
"meta_description": "Example product",
"meta_keywords": "example, product",
"updated_at": "2020-02-16T07:14:54.617Z",
"sku": "9238-WS",
"available": true,
"compare_at_price": "49.99",
"display_compare_at_price": "$49.99",
"localized_slugs": {},
"tags": [
"<string>"
],
"labels": [
"<string>"
]
},
"relationships": {
"variants": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"option_types": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"product_properties": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"taxons": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"images": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"default_variant": {
"data": {
"id": "<string>",
"type": "<string>"
}
},
"primary_variant": {
"data": {
"id": "<string>",
"type": "<string>"
}
}
}
}
]
}Query Parameters
Specify what related resources (relationships) you would like to receive in the response body. Eg.
product,option_values,images,filter_values
Specify the fields you would like returned in the response body. More information.
Response
200 - application/vnd.api+json
200 Success - Returns an array of variant objects.
Was this page helpful?
⌘I
List all Product Variants
const options = {method: 'GET'};
fetch('https://demo.spreecommerce.org/api/v2/storefront/products/{product_slug}/variants', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request GET \
--url https://demo.spreecommerce.org/api/v2/storefront/products/{product_slug}/variants{
"data": [
{
"id": "1",
"type": "variant",
"attributes": {
"sku": "SKU-1001",
"price": "15.99",
"currency": "USD",
"display_price": "$15.99",
"weight": "10",
"height": "10",
"width": "10",
"depth": "10",
"is_master": true,
"options_text": "Size: small, Color: red",
"options": [
{
"name": "<string>",
"value": "<string>",
"presentation": "<string>"
}
],
"purchasable": true,
"in_stock": true,
"backorderable": true
},
"relationships": {
"product": {
"data": {
"id": "<string>",
"type": "<string>"
}
},
"images": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"option_values": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
}
}
}
],
"meta": {
"count": 7,
"total_count": 145,
"total_pages": 10
},
"links": {
"self": "<string>",
"next": "<string>",
"prev": "<string>",
"last": "<string>",
"first": "<string>"
},
"included": [
{
"id": "1",
"type": "product",
"attributes": {
"name": "Example product",
"description": "Example description",
"available_on": "2012-10-17T03:43:57Z",
"slug": "example-product",
"price": "15.99",
"currency": "USD",
"display_price": "$15.99",
"purchasable": true,
"in_stock": true,
"backorderable": true,
"meta_description": "Example product",
"meta_keywords": "example, product",
"updated_at": "2020-02-16T07:14:54.617Z",
"sku": "9238-WS",
"available": true,
"compare_at_price": "49.99",
"display_compare_at_price": "$49.99",
"localized_slugs": {},
"tags": [
"<string>"
],
"labels": [
"<string>"
]
},
"relationships": {
"variants": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"option_types": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"product_properties": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"taxons": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"images": {
"data": [
{
"id": "<string>",
"type": "<string>"
}
]
},
"default_variant": {
"data": {
"id": "<string>",
"type": "<string>"
}
},
"primary_variant": {
"data": {
"id": "<string>",
"type": "<string>"
}
}
}
}
]
}
