Skip to main content
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));
{
  "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>"
          }
        }
      }
    }
  ]
}

Path Parameters

product_slug
string
required

Product Slug

Query Parameters

filter[options][color]
string

Find Variants that have the specified option (eg. color, size) and value (eg. red, XS)

page
integer

Number of requested page when paginating collection

per_page
integer

Number of requested records per page when paginating collection

include
string

Specify what related resources (relationships) you would like to receive in the response body. Eg.

product,option_values,images,filter_values

More information

fields[variant]
string

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.

data
Variant · object[]
required
meta
Pagination Meta · object
required
included
(Product · object | Image · object | Option Value · object)[]