curl https://api.khaime.com/api/v1/marketplace/products/501/variants \
-H "X-API-Key: pk_sandbox_your_key"
Marketplace
Get Product Variants
Retrieve the full variant tree for a product.
GET
/
marketplace
/
products
/
{productId}
/
variants
curl https://api.khaime.com/api/v1/marketplace/products/501/variants \
-H "X-API-Key: pk_sandbox_your_key"
Intro
Returns the complete variation → sub-variation → sub-variant tree for a product, exactly as written by Create/Replace Product Variants.Context
The read counterpart to Create/Replace Product Variants — since that endpoint’s own response is intentionally flat (no nested tree), this is the endpoint to call when you need the server-confirmed nested structure back, for example right after a POST, or when rendering a product’s options in a storefront integration. Works for any product you own or that belongs to an active sub-merchant in your marketplace.Hows
Path Parameters
integer
required
A product you own, or a product owned by an active sub-merchant in your marketplace.
Response
If the product has no variants configured yet, this returns
200 with data: null — it is not a 404. Treat data === null as “no variants,” not as an error.{
"success": true,
"message": "Variants retrieved successfully",
"data": {
"id": "b6b6c2b0-...-uuid",
"product_id": 501,
"variation_type": "size",
"variation_custom_label": "Size",
"has_sub_variants": true,
"total_quantity": 40,
"variations": [
{
"id": "v-11111111-1111-1111-1111-111111111111",
"sku": "SHIRT-M",
"variant_label": "Medium",
"variant_object": "{\"size\":\"M\"}",
"variation_quantity": 20,
"variation_add_price": 0,
"variation_cost_price": 0,
"order_index": 0,
"sub_variation": {
"id": "sv-...-uuid",
"sub_variation_type": "color",
"sub_variation_custom_label": "Color",
"sub_variation_total_quantity": 20,
"sub_variants": [
{
"id": "svt-...-uuid",
"sku": "SHIRT-M-RED",
"variant_label": "Red",
"variant_quantity": 20,
"subvariant_add_price": 0,
"subvariant_cost_price": 0
}
]
}
}
]
}
}
variations is ordered by order_index ascending; sub_variants is ordered by creation time (they don’t carry their own order_index). createdAt/updatedAt timestamps are stripped at every level of this response.
Error Codes
| Status | Error Code | Cause |
|---|---|---|
404 | PRODUCT_NOT_FOUND | Product doesn’t exist, or you don’t own it and aren’t its marketplace operator. |
curl https://api.khaime.com/api/v1/marketplace/products/501/variants \
-H "X-API-Key: pk_sandbox_your_key"
Whys
Returningdata: null with a 200 (rather than a 404) when no variants exist reflects that “this product has no variants” is a normal, expected state for a simple product — not an error condition. A storefront rendering a product page can check data === null to decide whether to show variant selectors at all, without needing to special-case a 404 into “no variants” versus “product not found” (the latter is a real 404, from the product lookup itself, not this endpoint’s variant data).
