Skip to content

Commit 253db7d

Browse files
feat(api): api update
1 parent 740b2d4 commit 253db7d

4 files changed

Lines changed: 65 additions & 23 deletions

File tree

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 40
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-c99300223257d60d7614e76585c62cfea40f43df0547db63c952b20c52f209f4.yml
3-
openapi_spec_hash: 1d4e473f3c566b7a1c3def11b6d84fe0
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-4f279e7b1f0a52f5c917d4256e17188dfe330ddf7495146e2b1611e812605fdc.yml
3+
openapi_spec_hash: 53a74c4cccbdec8590db38183840a446
44
config_hash: 920678668dd2da6f8966fbf1b8fde4e2

‎src/context/dev/resources/brand.py‎

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Union, Optional
5+
from typing import List, Union, Optional
66
from typing_extensions import Literal, overload
77

88
import httpx
@@ -1278,7 +1278,10 @@ def search(
12781278
self,
12791279
*,
12801280
query: str,
1281+
autocomplete: bool | Omit = omit,
1282+
query_by: List[Literal["name", "domain"]] | Omit = omit,
12811283
tags: SequenceNotStr[str] | Omit = omit,
1284+
typo_tolerance: int | Omit = omit,
12821285
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
12831286
# The extra values given here take precedence over values defined on the client or passed to this method.
12841287
extra_headers: Headers | None = None,
@@ -1287,23 +1290,25 @@ def search(
12871290
timeout: float | httpx.Timeout | None | NotGiven = not_given,
12881291
) -> BrandSearchResponse:
12891292
"""
1290-
Search brands by name or domain and get back up to 10 lightweight matches
1291-
(domain, name, logo). Name matches rank ahead of domain matches; within each
1292-
group the most popular brands come first: by Tranco rank, then market cap for
1293-
brands outside the Tranco list, with text relevance breaking ties. Matching is
1294-
prefix-based with no typo tolerance, so it is suited to autocomplete. Only
1295-
brands already in the Context.dev index are returned — use /brand/retrieve to
1296-
fetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit
1297-
per request on the Free and Starter plans.
1293+
Search indexed brands by name or domain
12981294
12991295
Args:
1300-
query: Search term, matched against brand names and domains by prefix (e.g. 'nike',
1296+
query: Search term, matched against the fields selected by queryBy (e.g. 'nike',
13011297
'nike.com', 'nik').
13021298
1299+
autocomplete: Whether the search term matches by prefix, so partial words match as they are
1300+
typed (e.g. 'nik' matches Nike). Set to false to match whole words only.
1301+
1302+
query_by: Fields to match the search term against, as a comma-separated list or repeated
1303+
parameter: 'name', 'domain', or both. Defaults to both.
1304+
13031305
tags: Optional comma-separated caller-defined tags for tracking this request. Tags are
13041306
recorded on the request's usage log and can be used to filter usage on the
13051307
dashboard usage page. Up to 20 tags, each 1-50 characters.
13061308
1309+
typo_tolerance: Maximum number of typos tolerated when matching, from 0 to 2. Defaults to 0 (no
1310+
typo tolerance).
1311+
13071312
extra_headers: Send extra headers
13081313
13091314
extra_query: Add additional query parameters to the request
@@ -1322,7 +1327,10 @@ def search(
13221327
query=maybe_transform(
13231328
{
13241329
"query": query,
1330+
"autocomplete": autocomplete,
1331+
"query_by": query_by,
13251332
"tags": tags,
1333+
"typo_tolerance": typo_tolerance,
13261334
},
13271335
brand_search_params.BrandSearchParams,
13281336
),
@@ -2583,7 +2591,10 @@ async def search(
25832591
self,
25842592
*,
25852593
query: str,
2594+
autocomplete: bool | Omit = omit,
2595+
query_by: List[Literal["name", "domain"]] | Omit = omit,
25862596
tags: SequenceNotStr[str] | Omit = omit,
2597+
typo_tolerance: int | Omit = omit,
25872598
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
25882599
# The extra values given here take precedence over values defined on the client or passed to this method.
25892600
extra_headers: Headers | None = None,
@@ -2592,23 +2603,25 @@ async def search(
25922603
timeout: float | httpx.Timeout | None | NotGiven = not_given,
25932604
) -> BrandSearchResponse:
25942605
"""
2595-
Search brands by name or domain and get back up to 10 lightweight matches
2596-
(domain, name, logo). Name matches rank ahead of domain matches; within each
2597-
group the most popular brands come first: by Tranco rank, then market cap for
2598-
brands outside the Tranco list, with text relevance breaking ties. Matching is
2599-
prefix-based with no typo tolerance, so it is suited to autocomplete. Only
2600-
brands already in the Context.dev index are returned — use /brand/retrieve to
2601-
fetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit
2602-
per request on the Free and Starter plans.
2606+
Search indexed brands by name or domain
26032607
26042608
Args:
2605-
query: Search term, matched against brand names and domains by prefix (e.g. 'nike',
2609+
query: Search term, matched against the fields selected by queryBy (e.g. 'nike',
26062610
'nike.com', 'nik').
26072611
2612+
autocomplete: Whether the search term matches by prefix, so partial words match as they are
2613+
typed (e.g. 'nik' matches Nike). Set to false to match whole words only.
2614+
2615+
query_by: Fields to match the search term against, as a comma-separated list or repeated
2616+
parameter: 'name', 'domain', or both. Defaults to both.
2617+
26082618
tags: Optional comma-separated caller-defined tags for tracking this request. Tags are
26092619
recorded on the request's usage log and can be used to filter usage on the
26102620
dashboard usage page. Up to 20 tags, each 1-50 characters.
26112621
2622+
typo_tolerance: Maximum number of typos tolerated when matching, from 0 to 2. Defaults to 0 (no
2623+
typo tolerance).
2624+
26122625
extra_headers: Send extra headers
26132626
26142627
extra_query: Add additional query parameters to the request
@@ -2627,7 +2640,10 @@ async def search(
26272640
query=await async_maybe_transform(
26282641
{
26292642
"query": query,
2643+
"autocomplete": autocomplete,
2644+
"query_by": query_by,
26302645
"tags": tags,
2646+
"typo_tolerance": typo_tolerance,
26312647
},
26322648
brand_search_params.BrandSearchParams,
26332649
),

‎src/context/dev/types/brand_search_params.py‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,43 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, TypedDict
5+
from typing import List
6+
from typing_extensions import Literal, Required, Annotated, TypedDict
67

78
from .._types import SequenceNotStr
9+
from .._utils import PropertyInfo
810

911
__all__ = ["BrandSearchParams"]
1012

1113

1214
class BrandSearchParams(TypedDict, total=False):
1315
query: Required[str]
14-
"""Search term, matched against brand names and domains by prefix (e.g.
16+
"""Search term, matched against the fields selected by queryBy (e.g.
1517
1618
'nike', 'nike.com', 'nik').
1719
"""
1820

21+
autocomplete: bool
22+
"""
23+
Whether the search term matches by prefix, so partial words match as they are
24+
typed (e.g. 'nik' matches Nike). Set to false to match whole words only.
25+
"""
26+
27+
query_by: Annotated[List[Literal["name", "domain"]], PropertyInfo(alias="queryBy")]
28+
"""
29+
Fields to match the search term against, as a comma-separated list or repeated
30+
parameter: 'name', 'domain', or both. Defaults to both.
31+
"""
32+
1933
tags: SequenceNotStr[str]
2034
"""Optional comma-separated caller-defined tags for tracking this request.
2135
2236
Tags are recorded on the request's usage log and can be used to filter usage on
2337
the dashboard usage page. Up to 20 tags, each 1-50 characters.
2438
"""
39+
40+
typo_tolerance: Annotated[int, PropertyInfo(alias="typoTolerance")]
41+
"""Maximum number of typos tolerated when matching, from 0 to 2.
42+
43+
Defaults to 0 (no typo tolerance).
44+
"""

‎tests/api_resources/test_brand.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,10 @@ def test_method_search(self, client: ContextDev) -> None:
389389
def test_method_search_with_all_params(self, client: ContextDev) -> None:
390390
brand = client.brand.search(
391391
query="x",
392+
autocomplete=True,
393+
query_by=["name"],
392394
tags=["production", "team-alpha"],
395+
typo_tolerance=0,
393396
)
394397
assert_matches_type(BrandSearchResponse, brand, path=["response"])
395398

@@ -793,7 +796,10 @@ async def test_method_search(self, async_client: AsyncContextDev) -> None:
793796
async def test_method_search_with_all_params(self, async_client: AsyncContextDev) -> None:
794797
brand = await async_client.brand.search(
795798
query="x",
799+
autocomplete=True,
800+
query_by=["name"],
796801
tags=["production", "team-alpha"],
802+
typo_tolerance=0,
797803
)
798804
assert_matches_type(BrandSearchResponse, brand, path=["response"])
799805

0 commit comments

Comments
 (0)