@@ -222,6 +222,7 @@ def __init__(self, api_config: APIConfig):
222222 environment = api_config .environment ,
223223 country_code = self .api_config .country .name ,
224224 )
225+ self .base_search_url = URLBuilder .search (self .api_config .environment )
225226
226227 def get (
227228 self ,
@@ -309,6 +310,35 @@ def text_search(
309310 )
310311 return typing .cast (requests .Response , r ).json ()
311312
313+ def search (
314+ self ,
315+ query : str ,
316+ page : int = 1 ,
317+ page_size : int = 24 ,
318+ sort_by : Optional [str ] = None ,
319+ ) -> JSONType :
320+ """Search products using the search-a-licious endpoint.
321+
322+ .. warning::
323+ This feature is in alpha. The search-a-licious API may
324+ change without notice.
325+
326+ :param query: the search query
327+ :param page: page number (starts at 1), defaults to 1
328+ :param page_size: number of results per page, defaults to 24
329+ :param sort_by: field to sort by, optional
330+ :return: search results dict with a 'hits' key containing products
331+ """
332+ params : dict = {"q" : query , "page" : page , "page_size" : page_size }
333+ if sort_by is not None :
334+ params ["sort_by" ] = sort_by
335+ resp = http_session .get (
336+ f"{ self .base_search_url } /search" ,
337+ params = params ,
338+ )
339+ resp .raise_for_status ()
340+ return typing .cast (JSONType , resp .json ())
341+
312342 def update (self , body : Dict [str , Any ]):
313343 """Create a new product or update an existing one."""
314344 if not body .get ("code" ):
0 commit comments