Method Signature
constructorio.browse.getBrowseFacetOptions(facetName, parameters?, networkParameters?)
Retrieves all available options for a specific facet (filter) in your catalog.
Parameters
The name of the facet to retrieve options for (e.g., ‘brand’, ‘color’, ‘size’).
Optional parameters to customize the request.
The section to retrieve facet options for.
Formatting options for the response.
Maximum depth for nested groups.
Network-specific parameters.
Request timeout in milliseconds.
Response
Returns a Promise that resolves to a GetBrowseFacetOptionsResponse object.
The facet options response data.
Array containing the requested facet with its options.
Human-readable facet name.
All available options for this facet.
Human-readable option name.
Number of results with this option.
Total number of options available for this facet.
Unique identifier for this request.
Examples
Get Brand Options
const brandOptions = await constructorio.browse.getBrowseFacetOptions('brand');
console.log('Available brands:', brandOptions.response.facets[0].options);
Get Color Options
const colorOptions = await constructorio.browse.getBrowseFacetOptions('color');
colorOptions.response.facets[0].options.forEach(color => {
console.log(`${color.display_name}: ${color.count} products`);
});
For a Specific Section
const sizeOptions = await constructorio.browse.getBrowseFacetOptions('size', {
section: 'Clothing'
});
Building a Filter Dropdown
async function loadBrandFilter() {
const response = await constructorio.browse.getBrowseFacetOptions('brand');
const brands = response.response.facets[0].options.map(option => ({
value: option.value,
label: option.display_name,
productCount: option.count
}));
// Populate dropdown
renderBrandDropdown(brands);
}
With Error Handling
try {
const response = await constructorio.browse.getBrowseFacetOptions('category');
if (response.response.facets.length > 0) {
const categories = response.response.facets[0].options;
console.log(`Found ${categories.length} categories`);
}
} catch (error) {
console.error('Failed to load category options:', error);
}
Custom Network Timeout
const priceRanges = await constructorio.browse.getBrowseFacetOptions(
'price_range',
{},
{ timeout: 3000 }
);
Use Cases
Dynamic Filter Population
Load facet options dynamically based on user interaction:
function onFacetExpand(facetName) {
constructorio.browse.getBrowseFacetOptions(facetName)
.then(response => {
const options = response.response.facets[0].options;
displayFacetOptions(facetName, options);
});
}
Facet Option Search
Implement type-ahead search within facet options for facets with many values.
Category Tree Building
For hierarchical facets like categories, use the options to build navigation trees.
Error Handling
try {
const response = await constructorio.browse.getBrowseFacetOptions('brand');
console.log('Options loaded successfully');
} catch (error) {
if (error.message.includes('facet not found')) {
console.error('Facet does not exist:', error);
} else {
console.error('Error loading facet options:', error);
}
}