get-product-detail
Method: GET
Path: /catalog/products/{product_id_or_slug}
Tags: Catalog
Summary
Retrieve a product detail
Description
Retrieves the details of an existing product. Supply either the unique product ID or the unique slug, and Commerce Engine will return the corresponding product information.
Storefront SDK Usage
SDK Method: sdk.catalog.getProductDetail()
Example:
typescript
// Get product by ID
const { data, error } = await sdk.catalog.getProductDetail(
{ product_id_or_slug: "prod_123" }
);
if (error) {
console.error("Failed to get product details:", error);
return;
}
console.log("Product:", data.product.name);
console.log("Price:", data.product.price);
console.log("Description:", data.product.description);
// Get product by slug
const { data: slugData, error: slugError } = await sdk.catalog.getProductDetail({
product_id_or_slug: "detox-candy"
});
// Override customer group ID for this specific request
const { data: overrideData, error: overrideError } = await sdk.catalog.getProductDetail(
{ product_id_or_slug: "detox-candy" },
{
"x-customer-group-id": "premium_customers" // Override default SDK config
}
);
if (slugError) {
console.error("Failed to get product by slug:", slugError);
return;
}
console.log("Product with custom pricing:", slugData.product.price);TypeScript Definition
typescript
"get-product-detail": {
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 The unique identifier of the product. Can be either the product ID or the slug. */
product_id_or_slug: 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: {
product: components["schemas"]["ProductDetail"];
};
};
};
};
401: components["responses"]["Unauthorized"];
404: components["responses"]["NotFound"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["parameters"]["CustomerGroupId"] | CustomerGroupId |
components["schemas"]["ProductDetail"] | ProductDetail |
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_or_slug (path): The unique identifier of the product. Can be either the product ID or the slug.
Responses
200
Success response
401
Not authorized for given operation on the Resource
404
Requested resource not found
OpenAPI Definition
json
{
"tags": [
"Catalog"
],
"operationId": "get-product-detail",
"summary": "Retrieve a product detail",
"description": "Retrieves the details of an existing product. Supply either the unique product ID or the unique slug, and Commerce Engine will return the corresponding product information.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/get-product-detail",
"description": "API reference for the get-product-detail 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_or_slug",
"in": "path",
"description": "The unique identifier of the product. Can be either the product ID or the slug.",
"required": true,
"schema": {
"type": "string",
"examples": [
"01XGCYCT8CRHXW4BG91JXCMDCW",
"detox-candy"
]
}
}
],
"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": {
"product": {
"$ref": "#/components/schemas/ProductDetail"
}
},
"required": [
"product"
],
"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": "getProductDetail"
}Auto-generated from OpenAPI spec and TypeScript definitions