Ending a multi-variation listing is quite complicated. Many parameters needs to be checked before calling EndItem API. Flowchart below helps in understanding the flow involved-
– How do I know if an Item is a variation one?
If GetItem API returns <Variations> tag, then it is a multi-variant listing
– How do I get quantity of a variation listing?
Inside <Variation> tag, there are <Quantity> and <QuantitySold> tags. Subtract the two to get available quantity