Difference between revisions of "API Variation"
From Spiffy Stores Knowledge Base
(14 intermediate revisions by 2 users not shown) | |||
Line 25: | Line 25: | ||
== Variation Properties == | == Variation Properties == | ||
− | + | {| class="reference" | |
− | + | !id | |
− | |||
− | |||
− | |||
− | {| class=" | ||
− | |||
|<code>{ "id" : 12345 }</code><br/> | |<code>{ "id" : 12345 }</code><br/> | ||
A unique numeric identifier for the variation. | A unique numeric identifier for the variation. | ||
|- | |- | ||
− | + | !product_id | |
|<code>{ "product_id" : 123456789 }</code><br/> | |<code>{ "product_id" : 123456789 }</code><br/> | ||
− | The unique numeric identifier for the product. | + | The unique numeric identifier for the product of this variation. |
|- | |- | ||
− | + | !title | |
|<code>{ "title" : "Red/Wool/Small" }</code><br/> | |<code>{ "title" : "Red/Wool/Small" }</code><br/> | ||
The title of the product variation. | The title of the product variation. | ||
|- | |- | ||
− | + | !position | |
|<code>{ "position" : 1 }</code><br/> | |<code>{ "position" : 1 }</code><br/> | ||
The position of the variation in the list of all product variantions. Position number 1 is at the top of the list. | The position of the variation in the list of all product variantions. Position number 1 is at the top of the list. | ||
|- | |- | ||
− | + | !option1 | |
|<code>{ "option1" : "Red" }</code><br/> | |<code>{ "option1" : "Red" }</code><br/> | ||
A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 1. | A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 1. | ||
|- | |- | ||
− | + | !option2 | |
|<code>{ "option2" : "Wool" }</code><br/> | |<code>{ "option2" : "Wool" }</code><br/> | ||
A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 2. | A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 2. | ||
|- | |- | ||
− | + | !option3 | |
|<code>{ "option3" : "Small" }</code><br/> | |<code>{ "option3" : "Small" }</code><br/> | ||
A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 3. | A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 3. | ||
|- | |- | ||
− | + | !sku | |
|<code>{ "sku" : "P123456REDWS" }</code><br/> | |<code>{ "sku" : "P123456REDWS" }</code><br/> | ||
A unique identifier for the product variation, normally used for stock tracking purposes. | A unique identifier for the product variation, normally used for stock tracking purposes. | ||
|- | |- | ||
− | |barcode | + | !location_code |
+ | |<code>{ "location_code" : "ROW23BIN12" }</code><br/> | ||
+ | A code which represents the physical location of the item. The code is used to sort the packing list so that items are listed by physical location to make order picking easier. | ||
+ | |- | ||
+ | !barcode | ||
|<code>{ "barcode" : "1234567809" }</code><br/> | |<code>{ "barcode" : "1234567809" }</code><br/> | ||
The barcode, which is usually the UPC or ISBN number for the product variation. | The barcode, which is usually the UPC or ISBN number for the product variation. | ||
|- | |- | ||
− | + | !price | |
|<code>{ "price" : 49.95 }</code><br/> | |<code>{ "price" : 49.95 }</code><br/> | ||
The price of the product variation. | The price of the product variation. | ||
|- | |- | ||
− | + | !wholesale_price | |
|<code>{ "wholesale_price" : 29.95 }</code><br/> | |<code>{ "wholesale_price" : 29.95 }</code><br/> | ||
The wholesale price of the product variation. This price is used whenever a customer with the wholesale attribute logs in to the store. | The wholesale price of the product variation. This price is used whenever a customer with the wholesale attribute logs in to the store. | ||
|- | |- | ||
− | + | !compare_at_price | |
|<code>{ "compare_at_price" : 69.95 }</code><br/> | |<code>{ "compare_at_price" : 69.95 }</code><br/> | ||
This price is used to show the regular price of a variation to highlight how much is being saved. | This price is used to show the regular price of a variation to highlight how much is being saved. | ||
|- | |- | ||
− | + | !discount | |
|<code>{ "discount" : 5.00 }</code><br/> | |<code>{ "discount" : 5.00 }</code><br/> | ||
This is the amount that this variation can have as a discount when it is eligible for a shopping cart discount. This amount overrides any general discount calculation for the cart. | This is the amount that this variation can have as a discount when it is eligible for a shopping cart discount. This amount overrides any general discount calculation for the cart. | ||
|- | |- | ||
− | + | !taxable | |
|<code>{ "taxable" : true }</code><br/> | |<code>{ "taxable" : true }</code><br/> | ||
Indicates whether the product variation is subject to tax. Some items, such as food or books may be exempt from taxes such as GST or VAT. | Indicates whether the product variation is subject to tax. Some items, such as food or books may be exempt from taxes such as GST or VAT. | ||
|- | |- | ||
− | + | !instalments | |
|<code>{ "instalments" : 1 }</code><br/> | |<code>{ "instalments" : 1 }</code><br/> | ||
If instalments are enabled for this product, then this indicates the number of instalments that must be paid for this variation. | If instalments are enabled for this product, then this indicates the number of instalments that must be paid for this variation. | ||
|- | |- | ||
− | + | !grams | |
|<code>{ "grams" : 200 }</code><br/> | |<code>{ "grams" : 200 }</code><br/> | ||
The weight of the product variation in grams. | The weight of the product variation in grams. | ||
|- | |- | ||
− | + | !length | |
|<code>{ "length" : 100 }</code><br/> | |<code>{ "length" : 100 }</code><br/> | ||
The length of the product variation in cms. | The length of the product variation in cms. | ||
|- | |- | ||
− | + | !width | |
|<code>{ "width" : 50 }</code><br/> | |<code>{ "width" : 50 }</code><br/> | ||
The width of the product variation in cms. | The width of the product variation in cms. | ||
|- | |- | ||
− | + | !height | |
|<code>{ "height" : 20 }</code><br/> | |<code>{ "height" : 20 }</code><br/> | ||
The height of the product variation in cms. | The height of the product variation in cms. | ||
|- | |- | ||
− | + | !inventory_quantity | |
|<code>{ "inventory_quantity" : 10 }</code><br/> | |<code>{ "inventory_quantity" : 10 }</code><br/> | ||
The number of items in stock for this product variation. | The number of items in stock for this product variation. | ||
|- | |- | ||
− | + | !old_inventory_quantity | |
|<code>{ "old_inventory_quantity" : 10 }</code><br/> | |<code>{ "old_inventory_quantity" : 10 }</code><br/> | ||
The original number of items in stock for this product variation. This value must be provided when attempting to update the inventory quantity. If the old_inventory_quantity no longer matches the actual inventory quantity because the value has been updated elsewhere, then the attempt to update the quantity will fail and should be retried. | The original number of items in stock for this product variation. This value must be provided when attempting to update the inventory quantity. If the old_inventory_quantity no longer matches the actual inventory quantity because the value has been updated elsewhere, then the attempt to update the quantity will fail and should be retried. | ||
|- | |- | ||
− | + | !inventory_quantity_adjustment | |
|<code>{ "inventory_quantity_adjustment" : 5 }</code><br/> | |<code>{ "inventory_quantity_adjustment" : 5 }</code><br/> | ||
If it is not important to determine the exact level of the inventory quantity, then an adjustment can be used instead to increment or decrement the inventory quantity by a certain amount. | If it is not important to determine the exact level of the inventory quantity, then an adjustment can be used instead to increment or decrement the inventory quantity by a certain amount. | ||
|- | |- | ||
− | + | !inventory_management | |
|<code>{ "inventory_management" : "spiffy" }</code><br/> | |<code>{ "inventory_management" : "spiffy" }</code><br/> | ||
Specifies whether or not Spiffy Stores tracks the number of items in stock for this product variation. Valid values are: | Specifies whether or not Spiffy Stores tracks the number of items in stock for this product variation. Valid values are: | ||
Line 125: | Line 124: | ||
* spiffy: Inventory tracking is enabled for this product variation. | * spiffy: Inventory tracking is enabled for this product variation. | ||
|- | |- | ||
− | + | !inventory_policy | |
|<code>{ "inventory_policy" : "continue" }</code><br/> | |<code>{ "inventory_policy" : "continue" }</code><br/> | ||
Specifies whether or not customers are allowed to place an order for a product variation when it's out of stock. Valid values are: | Specifies whether or not customers are allowed to place an order for a product variation when it's out of stock. Valid values are: | ||
Line 132: | Line 131: | ||
* archive: The product is hidden when the variation is out of stock, and customers are not allowed to place orders for the variation. | * archive: The product is hidden when the variation is out of stock, and customers are not allowed to place orders for the variation. | ||
|- | |- | ||
− | + | !fulfilment_service | |
|<code>{ "fulfilment_service" : "manual" }</code><br/> | |<code>{ "fulfilment_service" : "manual" }</code><br/> | ||
If orders are fulfilled by the store itself, then this is 'manual'. Otherwise the value is set to the fulfilment service that has been enabled for this product variation. | If orders are fulfilled by the store itself, then this is 'manual'. Otherwise the value is set to the fulfilment service that has been enabled for this product variation. | ||
|- | |- | ||
− | + | !shipping_code | |
|<code>{ "shipping_code" : "BULK_ITEM" }</code><br/> | |<code>{ "shipping_code" : "BULK_ITEM" }</code><br/> | ||
If a special shipping rate is required for this product variation, it is specified by the 'shipping_code'. This shipping rate overrides the default shipping rate for the destination. | If a special shipping rate is required for this product variation, it is specified by the 'shipping_code'. This shipping rate overrides the default shipping rate for the destination. | ||
|- | |- | ||
− | + | !free_shipping | |
|<code>{ "free_shipping" : false }</code><br/> | |<code>{ "free_shipping" : false }</code><br/> | ||
Indicates that this product variation is eligible for free shipping. | Indicates that this product variation is eligible for free shipping. | ||
|- | |- | ||
− | + | !requires_shipping | |
|<code>{ "requires_shipping" : true }</code><br/> | |<code>{ "requires_shipping" : true }</code><br/> | ||
Indicates that this product variation is a physical object that requires shipping. | Indicates that this product variation is a physical object that requires shipping. | ||
|- | |- | ||
− | + | !ship_separately | |
|<code>{ "ship_separately" : false }</code><br/> | |<code>{ "ship_separately" : false }</code><br/> | ||
Indicates that the item is bulky and cannot be added to the total cart weight for the shipping rate calculation. The item is assessed for shipping as an individual parcel, based on its weight and dimensions which are required for separate shipping. | Indicates that the item is bulky and cannot be added to the total cart weight for the shipping rate calculation. The item is assessed for shipping as an individual parcel, based on its weight and dimensions which are required for separate shipping. | ||
|- | |- | ||
− | + | !created_at | |
|<code>{ "created_at" : "2007-10-24T18:26:31Z" }</code><br/> | |<code>{ "created_at" : "2007-10-24T18:26:31Z" }</code><br/> | ||
The date and time when the product variation was created. The timestamp is in ISO 8601 format. | The date and time when the product variation was created. The timestamp is in ISO 8601 format. | ||
|- | |- | ||
− | + | !updated_at | |
|<code>{ "updated_at" : "2014-01-16T05:50:56Z" }</code><br/> | |<code>{ "updated_at" : "2014-01-16T05:50:56Z" }</code><br/> | ||
The date and time when the product variation was last updated. The timestamp is in ISO 8601 format. | The date and time when the product variation was last updated. The timestamp is in ISO 8601 format. | ||
+ | |- | ||
+ | !image_id | ||
+ | |<code>{ "image_id" : "123456789" }</code><br/> | ||
+ | The unique identifier of the image that is associated with this variation. | ||
|} | |} | ||
Line 166: | Line 169: | ||
Return a list of variations belonging to a product. | Return a list of variations belonging to a product. | ||
+ | |||
+ | === <code>GET /api/variations.json</code> === | ||
+ | |||
+ | Return a list of variations belonging to a store. | ||
==== Optional Parameters ==== | ==== Optional Parameters ==== | ||
− | {| class=" | + | {| class="reference" |
− | + | !limit | |
|Number of results returned. The default is 30, with a maximum of 50 in a single request. | |Number of results returned. The default is 30, with a maximum of 50 in a single request. | ||
|- | |- | ||
− | + | !page | |
|The number of the page to return. The number of results per page is set by the <code>limit</code> parameter. If more results are required, then submit the request again, increasing the page number each time. | |The number of the page to return. The number of results per page is set by the <code>limit</code> parameter. If more results are required, then submit the request again, increasing the page number each time. | ||
|- | |- | ||
− | |since_id | + | !ids |
+ | |A comma-separated list of variation ids. | ||
+ | |- | ||
+ | !since_id | ||
|Limit the results to only include objects which have an id greater than the given value. | |Limit the results to only include objects which have an id greater than the given value. | ||
|- | |- | ||
− | + | !created_at_min | |
|Return only the product variations created after the given date and time. Use the format "2014-12-31 12:00". | |Return only the product variations created after the given date and time. Use the format "2014-12-31 12:00". | ||
|- | |- | ||
− | + | !created_at_max | |
|Return only the product variations created before the given date and time. Use the format "2014-12-31 12:00". | |Return only the product variations created before the given date and time. Use the format "2014-12-31 12:00". | ||
|- | |- | ||
− | + | !updated_at_min | |
|Return only the product variations updated after the given date and time. Use the format "2014-12-31 12:00". | |Return only the product variations updated after the given date and time. Use the format "2014-12-31 12:00". | ||
|- | |- | ||
− | + | !updated_at_max | |
|Return only the product variations updated before the given date and time. Use the format "2014-12-31 12:00". | |Return only the product variations updated before the given date and time. Use the format "2014-12-31 12:00". | ||
|- | |- | ||
− | + | !fields | |
|A comma-separated list of fields to return in the response. | |A comma-separated list of fields to return in the response. | ||
|} | |} | ||
Line 210: | Line 220: | ||
"position": 1, | "position": 1, | ||
"sku": "123AAA", | "sku": "123AAA", | ||
+ | "location_code": "ROW12BIN3", | ||
"barcode": "", | "barcode": "", | ||
"price": "10.0", | "price": "10.0", | ||
Line 239: | Line 250: | ||
} | } | ||
] | ] | ||
+ | } | ||
+ | |||
+ | GET /api/variations.json?fields=product_id,inventory_quantity&updated_at_min=2014-11-01 12:00 | ||
+ | |||
+ | HTTP/1.1 200 OK | ||
+ | |||
+ | { | ||
+ | "variations" : [ | ||
+ | { "product_id" : 1929, "inventory_quantity" : 0 }, | ||
+ | { "product_id" : 1930, "inventory_quantity" : 0 }, | ||
+ | { "product_id" : 1504, "inventory_quantity" : 101 }, | ||
+ | { "product_id" : 1504, "inventory_quantity" : 0 } | ||
+ | ] | ||
} | } | ||
Line 254: | Line 278: | ||
Return a count of product variations. | Return a count of product variations. | ||
+ | |||
+ | === <code>GET /api/variations/count.json</code> === | ||
+ | |||
+ | Return a count of variations belonging to a store. | ||
==== Optional Parameters ==== | ==== Optional Parameters ==== | ||
− | {| class=" | + | {| class="reference" |
− | + | !since_id | |
|Limit the results to only include objects which have an id greater than the given value. | |Limit the results to only include objects which have an id greater than the given value. | ||
|- | |- | ||
− | + | !created_at_min | |
|Return only the product variations created after the given date and time. Use the format "2014-12-31 12:00". | |Return only the product variations created after the given date and time. Use the format "2014-12-31 12:00". | ||
|- | |- | ||
− | + | !created_at_max | |
|Return only the product variations created before the given date and time. Use the format "2014-12-31 12:00". | |Return only the product variations created before the given date and time. Use the format "2014-12-31 12:00". | ||
|- | |- | ||
− | + | !updated_at_min | |
|Return only the product variations updated after the given date and time. Use the format "2014-12-31 12:00". | |Return only the product variations updated after the given date and time. Use the format "2014-12-31 12:00". | ||
|- | |- | ||
− | + | !updated_at_max | |
|Return only the product variations updated before the given date and time. Use the format "2014-12-31 12:00". | |Return only the product variations updated before the given date and time. Use the format "2014-12-31 12:00". | ||
|} | |} | ||
Line 283: | Line 311: | ||
{ | { | ||
"count": 2 | "count": 2 | ||
+ | } | ||
+ | |||
+ | GET /api/variations/count.json | ||
+ | |||
+ | HTTP/1.1 200 OK | ||
+ | |||
+ | { | ||
+ | "count": 115 | ||
} | } | ||
Line 291: | Line 327: | ||
=== <code>GET /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json</code> === | === <code>GET /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json</code> === | ||
+ | |||
+ | Return a single product variation. | ||
+ | |||
+ | === <code>GET /api/variations/VARIATION_ID.json</code> === | ||
Return a single product variation. | Return a single product variation. | ||
Line 296: | Line 336: | ||
==== Optional Parameters ==== | ==== Optional Parameters ==== | ||
− | {| class=" | + | {| class="reference" |
− | + | !fields | |
|A comma-separated list of fields to return in the response. | |A comma-separated list of fields to return in the response. | ||
|} | |} | ||
Line 315: | Line 355: | ||
"position": 1, | "position": 1, | ||
"sku": "123AAA", | "sku": "123AAA", | ||
+ | "location_code": "ROW12BIN3", | ||
"barcode": "", | "barcode": "", | ||
"price": "10.0", | "price": "10.0", | ||
Line 342: | Line 383: | ||
} | } | ||
− | Alternative | + | Alternative forms |
GET /api/products/cute-puppy/variations/87675.json | GET /api/products/cute-puppy/variations/87675.json | ||
+ | GET /api/variations/87675.json | ||
</pre> | </pre> | ||
Line 370: | Line 412: | ||
=== <code>PUT /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json</code> === | === <code>PUT /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json</code> === | ||
+ | |||
+ | Update a product variation. | ||
+ | |||
+ | === <code>PUT /api/variations/VARIATION_ID.json</code> === | ||
Update a product variation. | Update a product variation. | ||
When you update a product variation, you must include the <code>id</code> parameter, which must match the variation_id specified in the POST URL. | When you update a product variation, you must include the <code>id</code> parameter, which must match the variation_id specified in the POST URL. | ||
+ | |||
+ | When you update a product variation using the second form, you must include the <code>product_id</code> parameter, which must match the id of the product for the variation. | ||
==== Example Request and Response ==== | ==== Example Request and Response ==== | ||
Line 433: | Line 481: | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | <br><br><br> | ||
+ | |||
+ | == Further Reference == | ||
+ | |||
+ | * [[An Introduction to the Spiffy Stores API]] | ||
+ | * [[Creating Private API Keys]] | ||
+ | * [[Using the API]] | ||
+ | * [[API Reference]] |
Latest revision as of 10:35, 20 May 2020
The Spiffy Stores API Variation object represents a product variation. A variation usually represents some physical version of a product that needs to be represented separately from other variations. Each product variation can have its inventory tracked separately.
You can view a product's variations, update them, create new ones, and delete them.
Contents
- 1 Accessing a Product
- 2 Variation Properties
- 3 Endpoints
- 3.1 GET /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations.json
- 3.2 GET /api/variations.json
- 3.3 GET /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/count.json
- 3.4 GET /api/variations/count.json
- 3.5 GET /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json
- 3.6 GET /api/variations/VARIATION_ID.json
- 3.7 POST /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations.json
- 3.8 PUT /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json
- 3.9 PUT /api/variations/VARIATION_ID.json
- 3.10 DELETE /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json
- 4 Further Reference
Accessing a Product
If you want to refer to a single Product then you will need to use the unique id that has been assigned to that object.
The object ids are internally generated by the software and cannot be created or assigned.
Alternatively, you may specify the object handle in place of the object id when requesting access to the object. The handle is the unique character string that is assigned to every product when it is created. The handle is used in the URL to display the product page.
For example, you may retrieve a product's variations in two ways.
GET /api/products/12345678/variations.json or GET /api/products/cute-dog/variations.json
The advantage of using the handle form of the request is that you don't need to search all the products first in order to determine the product id, as you will already know what the handle is. This will reduce the number of API calls that you need to make and greatly simplifies the amount of coding that is needed to manage your products.
Variation Properties
id | { "id" : 12345 } A unique numeric identifier for the variation. |
---|---|
product_id | { "product_id" : 123456789 } The unique numeric identifier for the product of this variation. |
title | { "title" : "Red/Wool/Small" } The title of the product variation. |
position | { "position" : 1 } The position of the variation in the list of all product variantions. Position number 1 is at the top of the list. |
option1 | { "option1" : "Red" } A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 1. |
option2 | { "option2" : "Wool" } A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 2. |
option3 | { "option3" : "Small" } A product can have up to 3 options. Each variation will have a unique combination of option values. This is the value of option 3. |
sku | { "sku" : "P123456REDWS" } A unique identifier for the product variation, normally used for stock tracking purposes. |
location_code | { "location_code" : "ROW23BIN12" } A code which represents the physical location of the item. The code is used to sort the packing list so that items are listed by physical location to make order picking easier. |
barcode | { "barcode" : "1234567809" } The barcode, which is usually the UPC or ISBN number for the product variation. |
price | { "price" : 49.95 } The price of the product variation. |
wholesale_price | { "wholesale_price" : 29.95 } The wholesale price of the product variation. This price is used whenever a customer with the wholesale attribute logs in to the store. |
compare_at_price | { "compare_at_price" : 69.95 } This price is used to show the regular price of a variation to highlight how much is being saved. |
discount | { "discount" : 5.00 } This is the amount that this variation can have as a discount when it is eligible for a shopping cart discount. This amount overrides any general discount calculation for the cart. |
taxable | { "taxable" : true } Indicates whether the product variation is subject to tax. Some items, such as food or books may be exempt from taxes such as GST or VAT. |
instalments | { "instalments" : 1 } If instalments are enabled for this product, then this indicates the number of instalments that must be paid for this variation. |
grams | { "grams" : 200 } The weight of the product variation in grams. |
length | { "length" : 100 } The length of the product variation in cms. |
width | { "width" : 50 } The width of the product variation in cms. |
height | { "height" : 20 } The height of the product variation in cms. |
inventory_quantity | { "inventory_quantity" : 10 } The number of items in stock for this product variation. |
old_inventory_quantity | { "old_inventory_quantity" : 10 } The original number of items in stock for this product variation. This value must be provided when attempting to update the inventory quantity. If the old_inventory_quantity no longer matches the actual inventory quantity because the value has been updated elsewhere, then the attempt to update the quantity will fail and should be retried. |
inventory_quantity_adjustment | { "inventory_quantity_adjustment" : 5 } If it is not important to determine the exact level of the inventory quantity, then an adjustment can be used instead to increment or decrement the inventory quantity by a certain amount. |
inventory_management | { "inventory_management" : "spiffy" } Specifies whether or not Spiffy Stores tracks the number of items in stock for this product variation. Valid values are:
|
inventory_policy | { "inventory_policy" : "continue" } Specifies whether or not customers are allowed to place an order for a product variation when it's out of stock. Valid values are:
|
fulfilment_service | { "fulfilment_service" : "manual" } If orders are fulfilled by the store itself, then this is 'manual'. Otherwise the value is set to the fulfilment service that has been enabled for this product variation. |
shipping_code | { "shipping_code" : "BULK_ITEM" } If a special shipping rate is required for this product variation, it is specified by the 'shipping_code'. This shipping rate overrides the default shipping rate for the destination. |
free_shipping | { "free_shipping" : false } Indicates that this product variation is eligible for free shipping. |
requires_shipping | { "requires_shipping" : true } Indicates that this product variation is a physical object that requires shipping. |
ship_separately | { "ship_separately" : false } Indicates that the item is bulky and cannot be added to the total cart weight for the shipping rate calculation. The item is assessed for shipping as an individual parcel, based on its weight and dimensions which are required for separate shipping. |
created_at | { "created_at" : "2007-10-24T18:26:31Z" } The date and time when the product variation was created. The timestamp is in ISO 8601 format. |
updated_at | { "updated_at" : "2014-01-16T05:50:56Z" } The date and time when the product variation was last updated. The timestamp is in ISO 8601 format. |
image_id | { "image_id" : "123456789" } The unique identifier of the image that is associated with this variation. |
Endpoints
GET /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations.json
Return a list of variations belonging to a product.
GET /api/variations.json
Return a list of variations belonging to a store.
Optional Parameters
limit | Number of results returned. The default is 30, with a maximum of 50 in a single request. |
---|---|
page | The number of the page to return. The number of results per page is set by the limit parameter. If more results are required, then submit the request again, increasing the page number each time.
|
ids | A comma-separated list of variation ids. |
since_id | Limit the results to only include objects which have an id greater than the given value. |
created_at_min | Return only the product variations created after the given date and time. Use the format "2014-12-31 12:00". |
created_at_max | Return only the product variations created before the given date and time. Use the format "2014-12-31 12:00". |
updated_at_min | Return only the product variations updated after the given date and time. Use the format "2014-12-31 12:00". |
updated_at_max | Return only the product variations updated before the given date and time. Use the format "2014-12-31 12:00". |
fields | A comma-separated list of fields to return in the response. |
Example Request and Response
GET /api/products/123456789/variations.json HTTP/1.1 200 OK { "variations" : [ { "id": 3139, "product_id": 123456789, "title": "Red/Wool", "position": 1, "sku": "123AAA", "location_code": "ROW12BIN3", "barcode": "", "price": "10.0", "wholesale_price": "0.0", "compare_at_price": "0.0", "discount": "0.0", "taxable": true, "instalments": 1, "grams": 500.0, "length": 0.0, "width": 0.0, "height": 0.0, "inventory_quantity": 50, "old_inventory_quantity": 50, "inventory_policy": "deny", "inventory_management": "spiffy", "fulfilment_service": "manual", "shipping_code": "", "free_shipping": false, "requires_shipping": true, "ship_separately": false, "created_at": "2014-11-20T23:10:50Z", "updated_at": "2014-11-20T23:10:51Z", "option1": "Red", "option2": "Wool" }, { ... } ] } GET /api/variations.json?fields=product_id,inventory_quantity&updated_at_min=2014-11-01 12:00 HTTP/1.1 200 OK { "variations" : [ { "product_id" : 1929, "inventory_quantity" : 0 }, { "product_id" : 1930, "inventory_quantity" : 0 }, { "product_id" : 1504, "inventory_quantity" : 101 }, { "product_id" : 1504, "inventory_quantity" : 0 } ] } Examples using filters GET /api/products/123456789/variations.json?fields=id,title Alternative form GET /api/products/fluffy-puppy/variations.json
GET /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/count.json
Return a count of product variations.
GET /api/variations/count.json
Return a count of variations belonging to a store.
Optional Parameters
since_id | Limit the results to only include objects which have an id greater than the given value. |
---|---|
created_at_min | Return only the product variations created after the given date and time. Use the format "2014-12-31 12:00". |
created_at_max | Return only the product variations created before the given date and time. Use the format "2014-12-31 12:00". |
updated_at_min | Return only the product variations updated after the given date and time. Use the format "2014-12-31 12:00". |
updated_at_max | Return only the product variations updated before the given date and time. Use the format "2014-12-31 12:00". |
Example Request and Response
GET /api/products/fluffy-puppy/variations/count.json HTTP/1.1 200 OK { "count": 2 } GET /api/variations/count.json HTTP/1.1 200 OK { "count": 115 } Examples using filters GET /api/products/123456789/variations/count.json?since_id=1000
GET /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json
Return a single product variation.
GET /api/variations/VARIATION_ID.json
Return a single product variation.
Optional Parameters
fields | A comma-separated list of fields to return in the response. |
---|
Example Request and Response
GET /api/products/123456789/variations/87675.json HTTP/1.1 200 OK { "variation": { "id": 3139, "product_id": 123456789, "title": "Red/Silk", "position": 1, "sku": "123AAA", "location_code": "ROW12BIN3", "barcode": "", "price": "10.0", "wholesale_price": "0.0", "compare_at_price": "0.0", "discount": "0.0", "taxable": true, "instalments": 1, "grams": 500.0, "length": 0.0, "width": 0.0, "height": 0.0, "inventory_quantity": 50, "old_inventory_quantity": 50, "inventory_policy": "deny", "inventory_management": "spiffy", "fulfilment_service": "manual", "shipping_code": "", "free_shipping": false, "requires_shipping": true, "ship_separately": false, "created_at": "2014-11-20T23:10:50Z", "updated_at": "2014-11-20T23:10:51Z", "option1": "Red", "option2": "Silk" } } Alternative forms GET /api/products/cute-puppy/variations/87675.json GET /api/variations/87675.json
POST /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations.json
Create a new product variation.
Example Request and Response
POST /api/products/fluffy-puppy/variations.json { "variation": { "option1": "Default Title", "price": "10.00", "sku" => "222222", "inventory_quantity" => 50 } } HTTP/1.1 201 Created
PUT /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json
Update a product variation.
PUT /api/variations/VARIATION_ID.json
Update a product variation.
When you update a product variation, you must include the id
parameter, which must match the variation_id specified in the POST URL.
When you update a product variation using the second form, you must include the product_id
parameter, which must match the id of the product for the variation.
Example Request and Response
PUT /api/products/123456789/variations/45678.json { "variation": { "id": 45678, "option1": "Blue", "price": "109.00" } } HTTP/1.1 200 OK PUT /api/products/123456789/variations/45678.json { "variation": { "id": 45678, "inventory_quantity": 100, "old_inventory_quantity": 10 } } HTTP/1.1 200 OK PUT /api/products/123456789/variations/45678.json { "variation": { "id": 45678, "inventory_quantity_adjustment": -10 } } HTTP/1.1 200 OK
DELETE /api/products/(OBJECT_ID|OBJECT_HANDLE)/variations/VARIATION_ID.json
Delete a product variation.
Example Request and Response
DELETE /api/products/123456789/variations/45678.json HTTP/1.1 200 OK {} Alternative form DELETE /api/products/cute-puppy/variations/45678.json