API Documentation: Objects: Product Variant

kpthill edited this page Apr 10, 2013 · 5 revisions

Go back to read introductory information and usage guidelines about the API.

Object name

variant

Associated Capabilities

read_products

Object Description

A Product Variant is an item for sale by the merchant, which is one of that merchant's products with an option, such as color or style, specified. For more, see the description in the Product documentation.

Product variants are always attached to products, and so our API only permits querying for the variants of a particular product, not all variants offered by a store.

The Lexity implementation of this API is intended to be familiar to Shopify developers, and so the fields that a product may contain are the same as those currently offered by Shopify. Because we do not store all of the data that Shopify does, some of these fields may be null. The provided fields are:

Field Description Notes
compare_at_price A price to compare the current price to. This could be the MSRP, or the regular price if the object is currently on sale, or something else.
created_at The date this object was created. Format: ISO 8601
fulfillment_service Always null. Not yet supported.
grams The item's weight in grams.
id A string containing the platform-specific unique product variant id.
inventory_management Always null. Not yet supported.
inventory_policy Always null. Not yet supported.
option1 The choice of the first option for this variant. For example, 'green' or 'XXL'.
option2 The choice of the second option for this variant.
option3 The choice of the third option for this variant.
position Always null. Not yet supported.
price The price of this item.
product_id A string containing the platform-specific unique product id, for the product that this is a variant of.
requires_shipping Always null. Not yet supported.
sku The SKU for this item. A string decided upon by the merchant - you cannot count on uniqueness between stores.
taxable Always null. Not yet supported.
title The name of this variant.
updated_at The date that this variant was last updated. Format: ISO 8601
inventory_quantity The number of units of this item in stock.

Support for these fields may vary among the different platforms we support.

Query Parameters Available for this Object:

Field Description Notes
since_id Only show variants with id greater than this value. Works by string comparison, even if the strings hold integers.
limit Limit of number of objects in the response. Defaults to 50, maximum allowed value is 250.
page For paginated responses, the page to show. Defaults to 1.
fields Comma-separated string with the fields to be returned in the response body. Returns all fields by default.

Available API Interactions

Get all variants for a product

Request

GET {base_url}/products/{product_id}/variants.json

Request data

(empty)

Example response

HTTP/1.1 200 OK

{
    "variants": [{
        "taxable": null,
        "product_id": "11968542",
        "id": "30426592",
        "fulfillment_service": null,
        "inventory_quantity": 5,
        "price": "19.00",
        "grams": null,
        "updated_at": "2010-05-14T02:02:42Z",
        "sku": null,
        "inventory_policy": null,
        "compare_at_price": null,
        "created_at": "2010-05-14T02:02:42Z",
        "requires_shipping": null,
        "inventory_management": null,
        "option1": "Medium",
        "position": null,
        "option2": "",
        "option3": "",
        "title": "Medium"
    }]
}

Get a variant by id

Request

GET {base_url}/products/{product_id}/variants/{variant_id}.json

Request data

(empty)

Example response

HTTP/1.1 200 OK

{
    "variant": {
        "taxable": null,
        "product_id": "11968542",
        "updated_at": "2010-05-14T02:02:42Z",
        "fulfillment_service": null,
        "title": "Medium",
        "price": "19.00",
        "inventory_management": null,
        "inventory_policy": null,
        "requires_shipping": null,
        "position": null,
        "grams": null,
        "option1": "Medium",
        "option2": "",
        "option3": "",
        "inventory_quantity": 5,
        "id": "30426592",
        "sku": null,
        "compare_at_price": null,
        "created_at": "2010-05-14T02:02:42Z"
    }
}

Count variants

Request

GET {base_url}/products/{product_id}/variants/count.json

Request data

(empty)

Example response

HTTP/1.1 200 OK

{
  "count": 1
}

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.