searchFacets method

Future<SearchFacetsOutput> searchFacets({
  1. List<SearchFacetType>? facetTypes,
  2. List<SearchFilter>? filters,
  3. String? nextToken,
  4. String? searchText,
})

Returns available facet values for filtering listings, such as categories, pricing models, fulfillment option types, publishers, and customer ratings. Each facet value includes a count of matching listings.

Parameter facetTypes : A list of specific facet types to retrieve. If empty or null, all available facets are returned.

Parameter filters : Filters to apply before retrieving facets. Multiple filters are combined with AND logic. Multiple values within the same filter are combined with OR logic.

Parameter nextToken : If nextToken is returned, there are more results available. Make the call again using the returned token to retrieve the next page.

Parameter searchText : The search query text to filter listings before retrieving facets.

Implementation

Future<SearchFacetsOutput> searchFacets({
  List<SearchFacetType>? facetTypes,
  List<SearchFilter>? filters,
  String? nextToken,
  String? searchText,
}) async {
  final $payload = <String, dynamic>{
    if (facetTypes != null)
      'facetTypes': facetTypes.map((e) => e.value).toList(),
    if (filters != null) 'filters': filters,
    if (nextToken != null) 'nextToken': nextToken,
    if (searchText != null) 'searchText': searchText,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/2026-02-05/searchFacets',
    exceptionFnMap: _exceptionFns,
  );
  return SearchFacetsOutput.fromJson(response);
}