list-product-variants
Method: GET
Path: /catalog/products/{product_id}/variants
Tags: Catalog
Summary
Retrieve product variants
Description
Retrieves the variants of an existing product. Supply the unique product ID, and Commerce Engine will return the corresponding product variants information.
Storefront SDK Usage
SDK Method: sdk.catalog.listProductVariants()
Example:
typescript
const { data, error } = await sdk.catalog.listProductVariants(
{ product_id: "prod_123" }
);
if (error) {
console.error("Failed to list product variants:", error);
return;
}
console.log("Variants found:", data.variants?.length || 0);
data.variants?.forEach(variant => {
console.log(`Variant: ${variant.name} - SKU: ${variant.sku} - Price: ${variant.price}`);
});
// Override customer group ID for this specific request
const { data: overrideData, error: overrideError } = await sdk.catalog.listProductVariants(
{ product_id: "prod_123" },
{
"x-customer-group-id": "wholesale_customers" // Override default SDK config
}
);TypeScript Definition
typescript
"list-product-variants": {
parameters: {
query?: {
/** @description Determines whether to include or exlude inventory details in response json */
inventory?: boolean;
};
header?: {
/** @description This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned. */
"x-customer-group-id"?: components["parameters"]["CustomerGroupId"];
};
path: {
/** @description ID of a particular product */
product_id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Success response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @example Products retrieved successfully. */
message: string;
success: boolean;
content: {
variants: components["schemas"]["Variant"][];
};
};
};
};
401: components["responses"]["Unauthorized"];
404: components["responses"]["NotFound"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["parameters"]["CustomerGroupId"] | CustomerGroupId |
components["schemas"]["Variant"] | Variant |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["NotFound"] | NotFound |
Parameters
- x-customer-group-id (header): This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned.
- inventory (query): Determines whether to include or exlude inventory details in response json
- product_id (path): ID of a particular product
Responses
200
Success response
401
Not authorized for given operation on the Resource
404
Requested resource not found
OpenAPI Definition
json
{
"tags": [
"Catalog"
],
"operationId": "list-product-variants",
"summary": "Retrieve product variants",
"description": "Retrieves the variants of an existing product. Supply the unique product ID, and Commerce Engine will return the corresponding product variants information.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/list-product-variants",
"description": "API reference for the list-product-variants operation"
},
"parameters": [
{
"$ref": "#/components/parameters/CustomerGroupId"
},
{
"name": "inventory",
"in": "query",
"description": "Determines whether to include or exlude inventory details in response json",
"schema": {
"type": "boolean"
}
},
{
"name": "product_id",
"in": "path",
"description": "ID of a particular product",
"required": true,
"schema": {
"type": "string",
"examples": [
"01H7YK0C86V9PGT0HXRJVEZXJQ"
]
}
}
],
"responses": {
"200": {
"description": "Success response",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"type": "string",
"examples": [
"Products retrieved successfully."
]
},
"success": {
"type": "boolean"
},
"content": {
"properties": {
"variants": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Variant"
}
}
},
"required": [
"variants"
],
"type": "object"
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/NotFound"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "catalog",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "listProductVariants"
}Auto-generated from OpenAPI spec and TypeScript definitions