Home > widget-integration > FilterAPI
FilterAPI class
API service for handling filter widget requests to the Boost filter engine.
This service provides functionality for fetching filtered product results from the Boost API. It manages request construction, caching, and response processing through extensible methods that allow customization for shop-specific requirements.
Signature:
export declare class FilterAPI extends BoostAPI
Extends: BoostAPI
Remarks
Key features: - Automatic caching of filter responses - Query parameter building with locale and B2B support - Flexible response type handling (JSON/HTML) - Support for pagination and filtering - Extensible parameter and response processing
Example
Basic usage:
const api = new FilterAPI(store, helper, appService);
const response = await api.fetchAPI(
'/collections/all',
'product-list',
{
additionParams: { page: 1, limit: 20 },
responseType: 'json'
}
);
Constructors
|
Constructor |
Modifiers |
Description |
|---|---|---|
|
(constructor)(store, helper, platformLoader, appService, b2bService) |
Creates a new FilterAPI instance with injected dependencies |
Properties
|
Property |
Modifiers |
Type |
Description |
|---|---|---|---|
|
| |||
|
| |||
|
| |||
|
| |||
|
|
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
|
Adds AND condition flags for filter options that require it. Checks filter options in state for | |
|
|
Adds collection scope and tag parameters from app configuration. Includes collection_id and associated tags from general settings when filtering within a specific collection context. Override to customize collection scoping or add additional collection-based parameters. | |
|
|
Adds customer identification and session tracking parameters to API request. Includes customer ID (if logged in) and marks the request as not a first load. The API uses customer ID for personalization. Override to add custom customer attributes or implement shop-specific customer tracking. | |
|
|
Adds custom parameters from global configuration. This method reads custom parameters from | |
|
|
Adds device type and viewport parameters to API request. Detects the current device type (mobile/tablet) based on viewport width and includes this information in the API request. The API uses this to return device-appropriate responses. Override to customize device detection logic or add additional device-specific parameters. | |
|
|
Adds or removes filter flag based on presence of filter parameters. Checks if any filter parameters (those starting with 'pf_') exist and adds a | |
|
|
Adds pagination parameters from filter state to API request params. Extracts the current page number from FilterStore pagination state and includes it in the API request. Override to customize pagination behavior or implement infinite scroll patterns. | |
|
| ||
|
|
Adds showFilterTree parameter based on filter toggle button state. Checks the filter toggle button state in FilterStore and includes showFilterTree flag if the filter tree should be displayed. This is used for mobile/off-canvas filter layouts. Override to customize filter tree visibility logic. | |
|
|
Adds sorting parameters from filter state to API request params. Extracts the sort value from FilterStore state and includes it in the API request. Override this method to customize sorting behavior, add custom sort options, or implement shop-specific sorting rules. | |
|
|
Applies filter-specific settings to query parameters. This method applies shop configuration settings such as sorting behavior, out-of-stock display options, and availability filtering. Override this method to customize filter settings based on shop-specific requirements. | |
|
|
Protected method for building query parameters - can be overridden for customization | |
|
| ||
|
Builds parameters for the API request from store state and additional params. Uses a functional pipeline approach to transform parameters through multiple stages. This method orchestrates the entire parameter building process by applying transformations for sorting, pagination, device detection, customer data, filters, and shop-specific settings. Override this method to customize the parameter building pipeline for shop-specific requirements. | ||
|
Clears all cached data | ||
|
Main method to fetch filter API data with caching support | ||
|
Gets the latest request cache key | ||
|
|
Gets template parsed by ID from app configuration. This method resolves a template by its ID from the TAE app configuration, checking both | |
|
|
Adds banner interleaving parameter if feature is enabled. Checks template metadata for banner interleaving feature flag and includes insert_banners parameter if enabled. This tells the API to include promotional banner content in the product results. Override to customize banner insertion logic. | |
|
|
Handles currency metadata from API response. This method updates shop currency settings (money_format, money_format_with_currency, currency) based on metadata returned from the API. Override this method to customize currency handling or apply shop-specific currency transformations. | |
|
|
Transforms pf_tag parameter to standard tag parameter format. Renames the filter-specific | |
|
|
Adds vendor parameter when on a vendor-specific page. Detects if the current page is a vendor page and extracts the vendor name from the URL query parameter 'q', then includes it in the API request. Override to customize vendor detection or add vendor-specific parameters. | |
|
|
Makes the actual API request to fetch filter data. This method handles both template-based rendering (when widgetId is provided) and standard JSON/HTML responses. It performs the HTTP request, processes the response data, and handles currency metadata. Override this method to customize request behavior such as adding authentication, custom headers, or implementing retry logic. | |
|
|
Merges additional parameters provided by caller into the parameter object. Combines any extra parameters passed to fetchAPI() with the base parameters built from filter state. Additional params take precedence over base params. Override to validate, transform, or filter additional parameters. |