Introduction to the Variety API
Varieties describe what a variant is. A variety is a dimension such as COLOR or SIZE. A variety table is one set of values for that dimension, such as EU shoe sizes. A variety value is one entry in that set, with a display name and a sort order.
Items and variants hold codes only. An item variant has varietyN, varietyNTable and varietyNValue for positions 1 to 4. They match type, code on a variety table, and type, table, value on a variety value.
To build a size or color picker that shows the same options as Business Central and the Shopify integration:
- Sync
GET /inventory/varietytableandGET /inventory/varietyvaluewithsync=trueandlastRowVersion, and keep them in a local cache keyed onid. Sync does not return deleted rows, so reload the cache in full now and then. See Replication. - Read the variants with
GET /inventory/itemvariant, or withGET /inventory/item?withVariants=true. Hide variants whereblockedis true. - For each position with a
varietyN, look up the variety table bytypeandcode. Skip the position when the table hasuseInVariantDescriptionset to false. The tabledescriptionis the dimension name. - Look up the value by
type,tableandvalue. The label is the table’spreTagInVariantDescriptionfollowed by the valuedescriptionwhen the table hasuseDescriptionFieldset, otherwise followed by the rawvalue. - When a variety table or value is not in your cache, show the raw code instead.
- Sort the values by
sortOrder, then byvalue. The response order is not guaranteed.
GET /inventory/variety gives the general name of each dimension, for example “Colour”, shared by all its variety tables. Use it when you need one name across products, such as a shop-wide filter. Its flags are only defaults for new variety tables; always use the flags on the variety table.
