77
88import httpx
99
10- from ..types import brand_retrieve_params , brand_retrieve_simplified_params
10+ from ..types import brand_search_params , brand_retrieve_params , brand_retrieve_simplified_params
1111from .._types import Body , Omit , Query , Headers , NotGiven , SequenceNotStr , omit , not_given
1212from .._utils import required_args , maybe_transform , async_maybe_transform
1313from .._compat import cached_property
1919 async_to_streamed_response_wrapper ,
2020)
2121from .._base_client import make_request_options
22+ from ..types .brand_search_response import BrandSearchResponse
2223from ..types .brand_retrieve_response import BrandRetrieveResponse
2324from ..types .brand_retrieve_simplified_response import BrandRetrieveSimplifiedResponse
2425
@@ -1273,6 +1274,61 @@ def retrieve_simplified(
12731274 cast_to = BrandRetrieveSimplifiedResponse ,
12741275 )
12751276
1277+ def search (
1278+ self ,
1279+ * ,
1280+ query : str ,
1281+ tags : SequenceNotStr [str ] | Omit = omit ,
1282+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1283+ # The extra values given here take precedence over values defined on the client or passed to this method.
1284+ extra_headers : Headers | None = None ,
1285+ extra_query : Query | None = None ,
1286+ extra_body : Body | None = None ,
1287+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
1288+ ) -> BrandSearchResponse :
1289+ """
1290+ Search brands by name or domain and get back up to 10 lightweight matches
1291+ (domain, name, logo), most popular first: by Tranco rank, then market cap for
1292+ brands outside the Tranco list, with text relevance breaking ties. Matching is
1293+ prefix-based with no typo tolerance, so it is suited to autocomplete. Only
1294+ brands already in the Context.dev index are returned — use /brand/retrieve to
1295+ fetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit
1296+ per request on the Free and Starter plans.
1297+
1298+ Args:
1299+ query: Search term, matched against brand names and domains by prefix (e.g. 'nike',
1300+ 'nike.com', 'nik').
1301+
1302+ tags: Optional comma-separated caller-defined tags for tracking this request. Tags are
1303+ recorded on the request's usage log and can be used to filter usage on the
1304+ dashboard usage page. Up to 20 tags, each 1-50 characters.
1305+
1306+ extra_headers: Send extra headers
1307+
1308+ extra_query: Add additional query parameters to the request
1309+
1310+ extra_body: Add additional JSON properties to the request
1311+
1312+ timeout: Override the client-level default timeout for this request, in seconds
1313+ """
1314+ return self ._get (
1315+ "/brand/search" ,
1316+ options = make_request_options (
1317+ extra_headers = extra_headers ,
1318+ extra_query = extra_query ,
1319+ extra_body = extra_body ,
1320+ timeout = timeout ,
1321+ query = maybe_transform (
1322+ {
1323+ "query" : query ,
1324+ "tags" : tags ,
1325+ },
1326+ brand_search_params .BrandSearchParams ,
1327+ ),
1328+ ),
1329+ cast_to = BrandSearchResponse ,
1330+ )
1331+
12761332
12771333class AsyncBrandResource (AsyncAPIResource ):
12781334 @cached_property
@@ -2522,6 +2578,61 @@ async def retrieve_simplified(
25222578 cast_to = BrandRetrieveSimplifiedResponse ,
25232579 )
25242580
2581+ async def search (
2582+ self ,
2583+ * ,
2584+ query : str ,
2585+ tags : SequenceNotStr [str ] | Omit = omit ,
2586+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2587+ # The extra values given here take precedence over values defined on the client or passed to this method.
2588+ extra_headers : Headers | None = None ,
2589+ extra_query : Query | None = None ,
2590+ extra_body : Body | None = None ,
2591+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
2592+ ) -> BrandSearchResponse :
2593+ """
2594+ Search brands by name or domain and get back up to 10 lightweight matches
2595+ (domain, name, logo), most popular first: by Tranco rank, then market cap for
2596+ brands outside the Tranco list, with text relevance breaking ties. Matching is
2597+ prefix-based with no typo tolerance, so it is suited to autocomplete. Only
2598+ brands already in the Context.dev index are returned — use /brand/retrieve to
2599+ fetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit
2600+ per request on the Free and Starter plans.
2601+
2602+ Args:
2603+ query: Search term, matched against brand names and domains by prefix (e.g. 'nike',
2604+ 'nike.com', 'nik').
2605+
2606+ tags: Optional comma-separated caller-defined tags for tracking this request. Tags are
2607+ recorded on the request's usage log and can be used to filter usage on the
2608+ dashboard usage page. Up to 20 tags, each 1-50 characters.
2609+
2610+ extra_headers: Send extra headers
2611+
2612+ extra_query: Add additional query parameters to the request
2613+
2614+ extra_body: Add additional JSON properties to the request
2615+
2616+ timeout: Override the client-level default timeout for this request, in seconds
2617+ """
2618+ return await self ._get (
2619+ "/brand/search" ,
2620+ options = make_request_options (
2621+ extra_headers = extra_headers ,
2622+ extra_query = extra_query ,
2623+ extra_body = extra_body ,
2624+ timeout = timeout ,
2625+ query = await async_maybe_transform (
2626+ {
2627+ "query" : query ,
2628+ "tags" : tags ,
2629+ },
2630+ brand_search_params .BrandSearchParams ,
2631+ ),
2632+ ),
2633+ cast_to = BrandSearchResponse ,
2634+ )
2635+
25252636
25262637class BrandResourceWithRawResponse :
25272638 def __init__ (self , brand : BrandResource ) -> None :
@@ -2533,6 +2644,9 @@ def __init__(self, brand: BrandResource) -> None:
25332644 self .retrieve_simplified = to_raw_response_wrapper (
25342645 brand .retrieve_simplified ,
25352646 )
2647+ self .search = to_raw_response_wrapper (
2648+ brand .search ,
2649+ )
25362650
25372651
25382652class AsyncBrandResourceWithRawResponse :
@@ -2545,6 +2659,9 @@ def __init__(self, brand: AsyncBrandResource) -> None:
25452659 self .retrieve_simplified = async_to_raw_response_wrapper (
25462660 brand .retrieve_simplified ,
25472661 )
2662+ self .search = async_to_raw_response_wrapper (
2663+ brand .search ,
2664+ )
25482665
25492666
25502667class BrandResourceWithStreamingResponse :
@@ -2557,6 +2674,9 @@ def __init__(self, brand: BrandResource) -> None:
25572674 self .retrieve_simplified = to_streamed_response_wrapper (
25582675 brand .retrieve_simplified ,
25592676 )
2677+ self .search = to_streamed_response_wrapper (
2678+ brand .search ,
2679+ )
25602680
25612681
25622682class AsyncBrandResourceWithStreamingResponse :
@@ -2569,3 +2689,6 @@ def __init__(self, brand: AsyncBrandResource) -> None:
25692689 self .retrieve_simplified = async_to_streamed_response_wrapper (
25702690 brand .retrieve_simplified ,
25712691 )
2692+ self .search = async_to_streamed_response_wrapper (
2693+ brand .search ,
2694+ )
0 commit comments