Method Signature
constructorio.browse.getBrowseFacets(parameters?, networkParameters?)
Retrieves all available facets (filter options) for browse results without requiring a specific filter selection.
Parameters
Optional parameters to customize the facets request.
The page number of facets to retrieve. Defaults to 1.
The number of facets to skip. Cannot be used with page.
Number of facet options to return per page. Defaults to 30.
The section to retrieve facets for.
Formatting options for the response.
Maximum depth for nested groups.
Starting group path for hierarchical data.
Network-specific parameters.
Request timeout in milliseconds.
Response
Returns a Promise that resolves to a GetBrowseFacetsResponse object.
The request parameters that were sent.
The facets response data.
Array of available facets with their options.
The facet name/identifier.
Human-readable facet name.
The facet type (e.g., ‘multiple’, ‘range’).
Available options for this facet.
Total number of facets available.
Unique identifier for this request.
Examples
Basic Usage
const facetsResponse = await constructorio.browse.getBrowseFacets();
console.log('Available facets:', facetsResponse.response.facets);
const facetsResponse = await constructorio.browse.getBrowseFacets({
page: 1,
resultsPerPage: 50
});
facetsResponse.response.facets.forEach(facet => {
console.log(`${facet.display_name}: ${facet.options.length} options`);
});
For a Specific Section
const facetsResponse = await constructorio.browse.getBrowseFacets({
section: 'Products'
});
With Custom Timeout
const facetsResponse = await constructorio.browse.getBrowseFacets(
{},
{ timeout: 5000 }
);
Processing Facets for UI
const facetsResponse = await constructorio.browse.getBrowseFacets();
const facetFilters = facetsResponse.response.facets.map(facet => ({
id: facet.name,
label: facet.display_name,
type: facet.type,
options: facet.options.map(opt => ({
value: opt.value,
label: opt.display_name,
count: opt.count
}))
}));
console.log('Processed facets:', facetFilters);
Use Cases
Building Faceted Search UI
Use getBrowseFacets() to populate filter options in your search/browse interface:
async function loadFilterOptions() {
const facetsResponse = await constructorio.browse.getBrowseFacets();
// Render facets in your UI
renderFilters(facetsResponse.response.facets);
}
Discovering Available Filters
Retrieve all available facets to understand what filtering options exist in your catalog.
Error Handling
try {
const facetsResponse = await constructorio.browse.getBrowseFacets();
console.log('Facets loaded successfully');
} catch (error) {
console.error('Error loading facets:', error);
}