search-products
Method: POST
Path: /catalog/products/search
Tags: Catalog
Summary
Search products
Description
Search for products matching a specific words or characters given.
Storefront SDK Usage
SDK Method: sdk.catalog.searchProducts()
Example:
typescript
const { data, error } = await sdk.catalog.searchProducts({
query: "smartphone",
filters: {
category: ["electronics", "mobile"],
price_range: { min: 100, max: 1000 },
brand: ["Apple", "Samsung"] // facet names depend on product configuration
},
page: 1,
limit: 20
});
if (error) {
console.error("Failed to search products:", error);
return;
}
console.log("Search results:", data.skus?.length || 0, "products found");
console.log("Facet distribution:", data.facet_distribution);
console.log("Price range:", data.facet_stats.price_range);
data.skus?.forEach(sku => {
console.log(`Found: ${sku.name} - ${sku.price}`);
});
// Override customer group ID for this specific request
const { data: overrideData, error: overrideError } = await sdk.catalog.searchProducts(
{
query: "laptop",
filters: { category: ["computers"] }
},
{
"x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
}
);TypeScript Definition
typescript
"search-products": {
parameters: {
query?: never;
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?: never;
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["SearchProduct"];
};
};
responses: {
/** @description Success response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
message: string;
success: boolean;
content: {
skus: components["schemas"]["Item"][];
facet_distribution: {
[key: string]: {
[key: string]: number;
};
};
facet_stats: {
[key: string]: {
min: number;
max: number;
};
};
pagination: components["schemas"]["Pagination"];
};
};
};
};
401: components["responses"]["Unauthorized"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["parameters"]["CustomerGroupId"] | CustomerGroupId |
components["schemas"]["SearchProduct"] | SearchProduct |
components["schemas"]["Item"] | Item |
components["schemas"]["Pagination"] | Pagination |
components["responses"]["Unauthorized"] | Unauthorized |
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.
Request Body
Content Types: application/json
Responses
200
Success response
401
Not authorized for given operation on the Resource
OpenAPI Definition
json
{
"tags": [
"Catalog"
],
"operationId": "search-products",
"summary": "Search products",
"description": "Search for products matching a specific words or characters given.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/search-products",
"description": "API reference for the search-products operation"
},
"parameters": [
{
"$ref": "#/components/parameters/CustomerGroupId"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SearchProduct"
}
}
}
},
"responses": {
"200": {
"description": "Success response",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"type": "string"
},
"success": {
"type": "boolean"
},
"content": {
"properties": {
"skus": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Item"
}
},
"facet_distribution": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {
"type": "integer"
}
}
},
"facet_stats": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"min": {
"type": "number"
},
"max": {
"type": "number"
}
},
"required": [
"min",
"max"
]
}
},
"pagination": {
"$ref": "#/components/schemas/Pagination"
}
},
"required": [
"skus",
"facet_distribution",
"facet_stats",
"pagination"
],
"type": "object"
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "catalog",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "searchProducts"
}Auto-generated from OpenAPI spec and TypeScript definitions