> ## Documentation Index
> Fetch the complete documentation index at: https://spreecommerce.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.



## OpenAPI

````yaml /api-reference/storefront.yaml get /api/v2/storefront/products/{product_slug}/variants
openapi: 3.0.3
info:
  version: 2.0.0
  title: Storefront API
  description: >-
    Storefront API is a modern REST API based on the [JSON API
    spec](https://jsonapi.org/) which provides you with all the necessary
    endpoints to build amazing user interfaces either in JavaScript frameworks
    or native mobile libraries.


    Import to
    [Postman](https://raw.githubusercontent.com/spree/spree/main/docs/api-reference/storefront.yaml)
  contact:
    name: Vendo Connect Inc.
    url: https://spreecommerce.org
    email: hello@spreecommerce.org
  license:
    name: BSD-3-Clause
    url: https://github.com/spree/spree/blob/main/LICENSE.md
servers:
  - url: https://demo.spreecommerce.org
    description: demo
  - url: http://localhost:3000
    description: localhost
security: []
tags:
  - name: Account
  - name: Account / Address
  - name: Account / Credit Cards
  - name: Account / Orders
  - name: Cart
  - name: Cart / Line Items
  - name: Cart / Coupons
  - name: Cart / Other
  - name: Checkout
  - name: Checkout / State
  - name: Checkout / Shipments
  - name: Checkout / Payments
  - name: Checkout / Store Credit
  - name: Stripe
  - name: Adyen
  - name: Countries
  - name: Digital Downloads
  - name: Order Status
  - name: Products
  - name: Variants
  - name: Stores
  - name: Policies
  - name: Taxons
  - name: Vendors
  - name: Wishlists
  - name: Wishlists / Wished Items
paths:
  /api/v2/storefront/products/{product_slug}/variants:
    get:
      tags:
        - Variants
      summary: List all Product Variants
      description: |-
        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.
      operationId: variants-list
      parameters:
        - $ref: '#/components/parameters/ProductSlug'
        - in: query
          name: filter[options][color]
          schema:
            type: string
          example: red
          description: >-
            Find Variants that have the specified option (eg. color, size) and
            value (eg. red, XS)
        - $ref: '#/components/parameters/PageParam'
        - $ref: '#/components/parameters/PerPageParam'
        - $ref: '#/components/parameters/VariantIncludeParam'
        - $ref: '#/components/parameters/SparseFieldsVariant'
      responses:
        '200':
          $ref: '#/components/responses/VariantList'
components:
  parameters:
    ProductSlug:
      name: product_slug
      in: path
      required: true
      description: Product Slug
      schema:
        type: string
      example: knitted-high-neck-sweater
    PageParam:
      name: page
      in: query
      description: Number of requested page when paginating collection
      schema:
        type: integer
      example: 1
    PerPageParam:
      name: per_page
      in: query
      description: Number of requested records per page when paginating collection
      schema:
        type: integer
      example: 25
    VariantIncludeParam:
      name: include
      in: query
      schema:
        type: string
      description: >-
        Specify what related resources (relationships) you would like to receive
        in the response body. Eg.


        ```

        product,option_values,images,filter_values

        ```


        [More information](https://jsonapi.org/format/#fetching-includes)
      example: product,option_values,images,filter_values
    SparseFieldsVariant:
      name: fields[variant]
      in: query
      description: >-
        Specify the fields you would like returned in the response body. [More
        information](https://jsonapi.org/format/#fetching-sparse-fieldsets).
      schema:
        type: string
      example: price,currency,options,options_text
  responses:
    VariantList:
      description: 200 Success - Returns an array of `variant` objects.
      content:
        application/vnd.api+json:
          schema:
            type: object
            properties:
              data:
                type: array
                items:
                  $ref: '#/components/schemas/Variant'
              included:
                type: array
                items:
                  $ref: '#/components/schemas/VariantIncludes'
              meta:
                $ref: '#/components/schemas/ListMeta'
              links:
                $ref: '#/components/schemas/ListLinks'
            required:
              - data
              - meta
              - links
  schemas:
    Variant:
      title: Variant
      description: >-
        Variant records track the individual variants of a Product. Variants are
        of two types: master variants and normal variants.
      x-examples: {}
      type: object
      x-internal: false
      properties:
        id:
          type: string
          example: '1'
        type:
          type: string
          default: variant
        attributes:
          type: object
          properties:
            sku:
              type: string
              example: SKU-1001
            price:
              type: string
              example: '15.99'
            currency:
              type: string
              example: USD
            display_price:
              type: string
              example: $15.99
            weight:
              type: string
              example: '10'
              nullable: true
            height:
              type: string
              example: '10'
              nullable: true
            width:
              type: string
              example: '10'
              nullable: true
            depth:
              type: string
              example: '10'
              nullable: true
            is_master:
              type: boolean
              description: Indicates if Variant is the master Variant
            options_text:
              type: string
              example: 'Size: small, Color: red'
            options:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                  value:
                    type: string
                  presentation:
                    type: string
            purchasable:
              type: boolean
              description: Indicates if Variant is in stock or backorderable
            in_stock:
              type: boolean
              description: Indicates if Variant is in stock
            backorderable:
              type: boolean
        relationships:
          type: object
          properties:
            product:
              type: object
              properties:
                data:
                  $ref: '#/components/schemas/Relation'
            images:
              type: object
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
            option_values:
              type: object
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
      required:
        - id
        - type
        - attributes
        - relationships
    VariantIncludes:
      x-internal: true
      title: Product Includes
      anyOf:
        - $ref: '#/components/schemas/Product'
        - $ref: '#/components/schemas/Image'
        - $ref: '#/components/schemas/OptionValue'
    ListMeta:
      type: object
      x-internal: false
      title: Pagination Meta
      properties:
        count:
          type: number
          example: 7
          description: Number of items on the current listing
        total_count:
          type: number
          example: 145
          description: Number of all items matching the criteria
        total_pages:
          type: number
          example: 10
          description: Number of all pages containing items matching the criteria
    ListLinks:
      x-internal: false
      type: object
      title: Pagination Links
      properties:
        self:
          type: string
          description: URL to the current page of the listing
        next:
          type: string
          description: URL to the next page of the listing
        prev:
          type: string
          description: URL to the previous page of the listing
        last:
          type: string
          description: URL to the last page of the listing
        first:
          type: string
          description: URL to the first page of the listing
    Relation:
      type: object
      nullable: true
      properties:
        id:
          type: string
        type:
          type: string
      required:
        - id
        - type
      x-internal: false
      description: ''
    Product:
      type: object
      title: Product
      x-internal: false
      properties:
        id:
          type: string
          example: '1'
        type:
          type: string
          default: product
        attributes:
          type: object
          properties:
            name:
              type: string
              example: Example product
            description:
              type: string
              example: Example description
              nullable: true
            available_on:
              type: string
              example: '2012-10-17T03:43:57Z'
              nullable: true
            slug:
              type: string
              example: example-product
            price:
              type: string
              example: '15.99'
              nullable: true
            currency:
              type: string
              example: USD
            display_price:
              type: string
              example: $15.99
              nullable: true
            purchasable:
              type: boolean
              description: Indicates if any of Variants are in stock or backorderable
            in_stock:
              type: boolean
              description: Indicates if any of Variants are in stock
            backorderable:
              type: boolean
              description: Indicates if any of Variants are backeorderable
            meta_description:
              type: string
              example: Example product
              nullable: true
            meta_keywords:
              type: string
              example: example, product
              nullable: true
            updated_at:
              $ref: '#/components/schemas/Timestamp'
            sku:
              type: string
              example: 9238-WS
            available:
              type: boolean
            compare_at_price:
              type: string
              example: '49.99'
              nullable: true
            display_compare_at_price:
              type: string
              example: $49.99
              nullable: true
            localized_slugs:
              type: object
              description: Provides product's slugs in other locales
            tags:
              type: array
              items:
                type: string
              description: List of tags associated with the product
            labels:
              type: array
              items:
                type: string
              description: List of labels associated with the product
        relationships:
          type: object
          properties:
            variants:
              type: object
              description: List of Product Variants, excluding Master Variant
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
            option_types:
              type: object
              description: List of Product Option Types
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
            product_properties:
              type: object
              description: List of Product Properties
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
            taxons:
              type: object
              description: List of Taxons associated with this Product
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
            images:
              type: object
              description: List of Images associated with this Product
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
            default_variant:
              type: object
              description: The default Variant for this product
              properties:
                data:
                  $ref: '#/components/schemas/Relation'
            primary_variant:
              type: object
              description: The Primary Variant for this product
              properties:
                data:
                  $ref: '#/components/schemas/Relation'
      required:
        - id
        - type
        - attributes
        - relationships
    Image:
      type: object
      properties:
        id:
          type: string
          example: '1'
        type:
          type: string
          default: image
        attributes:
          type: object
          properties:
            position:
              type: integer
              description: Sort order of images set in the Admin Panel
              example: 0
              minimum: 0
            styles:
              type: array
              description: An array of pre-scaled image styles
              items:
                $ref: '#/components/schemas/ImageStyle'
      required:
        - id
        - type
        - attributes
      title: Image
      x-internal: false
    OptionValue:
      title: Option Value
      type: object
      x-internal: true
      properties:
        id:
          type: string
          example: '1'
        type:
          type: string
          default: option_value
        attributes:
          type: object
          properties:
            name:
              type: string
              example: color
            presentation:
              type: string
              example: Color
            position:
              type: integer
              example: 1
        relationships:
          type: object
          properties:
            option_type:
              type: object
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
            filter_value:
              type: object
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/Relation'
      required:
        - id
        - type
        - attributes
        - relationships
    Timestamp:
      type: string
      format: date-time
      example: '2020-02-16T07:14:54.617Z'
      x-internal: false
      title: Time Stamp
      x-examples:
        example-1: '2020-02-16T07:14:54.617Z'
    ImageStyle:
      x-internal: false
      title: Image Style
      type: object
      properties:
        url:
          type: string
          example: >-
            http://localhost:3000/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJbWQyWVhKcFlXNTBjeTltWm1sMmRURlNORFpZWjJaSFpYUkdZMjk2WWsxM1RHWXZNVGs1T1RCak5XVmlNamN4TlRnd1pqVTBabUpqTWpCbFkyVXhZMlZpTTJFd05ERTJZemMzT0dKaE5tSTFNREkyT0dKaFpqa3paV1JtWTJWaE16aGxaQVk2QmtWVSIsImV4cCI6IjIwMTgtMDYtMjRUMTM6NTk6NTguOTY5WiIsInB1ciI6ImJsb2Jfa2V5In19--5e9ff358dc747f73754e332678c5762114ac6f3f/ror_jr_spaghetti.jpeg?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D%22ror_jr_spaghetti.jpeg%22%3B+filename%2A%3DUTF-8%27%27ror_jr_spaghetti.jpeg
          description: Absolute URL of the uploaded image in selected style (width/height)
        width:
          type: integer
          example: 1920
          description: Actual width of image
        height:
          type: integer
          example: 1080
          description: Actual height of image

````