Home > widget-integration > FilterAPI > addDeviceParams

FilterAPI.addDeviceParams() method

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.

Signature:

protected addDeviceParams(params: FilterAPIParams): FilterAPIParams;

Parameters

Parameter

Type

Description

params

FilterAPIParams

Current filter parameters being built

Returns:

FilterAPIParams

Enhanced parameters with isMobile and isTabletPortraitMax flags

Remarks

Device Detection: - Reads breakpoint from template settings (default: 768px for tablet portrait max) - Uses FilterHelper.isMobile() for detection - Both flags use the same breakpoint check currently

Example

Override to add custom device parameters:

window.boostWidgetIntegration.extend('FilterAPI', (FilterAPI) => {
  return class CustomFilterAPI extends FilterAPI {
    protected addDeviceParams(params) {
      const enhanced = super.addDeviceParams(params);
      // Add retina display detection for high-res images
      enhanced.isRetina = window.devicePixelRatio > 1;
      // Add custom mobile breakpoint for specific shops
      enhanced.isSmallMobile = window.innerWidth < 375;
      return enhanced;
    }
  };
});