searchListings method

Future<SearchListingsOutput> searchListings({
  1. List<SearchFilter>? filters,
  2. int? maxResults,
  3. String? nextToken,
  4. String? searchText,
  5. SearchListingsSortBy? sortBy,
  6. SearchListingsSortOrder? sortOrder,
})

Returns a list of product listings based on search criteria and filters. You can search by keyword, filter by category, pricing model, fulfillment type, and other attributes, and sort results by relevance or customer rating.

Parameter filters : Filters to narrow search results. Multiple filters are combined with AND logic. Multiple values within the same filter are combined with OR logic.

Parameter maxResults : The maximum number of results that are returned per call. You can use nextToken to get more results.

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 find relevant listings.

Parameter sortBy : The field to sort results by. Valid values are RELEVANCE and AVERAGE_CUSTOMER_RATING.

Parameter sortOrder : The sort direction. Valid values are DESCENDING and ASCENDING.

Implementation

Future<SearchListingsOutput> searchListings({
  List<SearchFilter>? filters,
  int? maxResults,
  String? nextToken,
  String? searchText,
  SearchListingsSortBy? sortBy,
  SearchListingsSortOrder? sortOrder,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  final $payload = <String, dynamic>{
    if (filters != null) 'filters': filters,
    if (maxResults != null) 'maxResults': maxResults,
    if (nextToken != null) 'nextToken': nextToken,
    if (searchText != null) 'searchText': searchText,
    if (sortBy != null) 'sortBy': sortBy.value,
    if (sortOrder != null) 'sortOrder': sortOrder.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/2026-02-05/searchListings',
    exceptionFnMap: _exceptionFns,
  );
  return SearchListingsOutput.fromJson(response);
}