Skip to content

Commit 499fb3f

Browse files
feat(api): api update
1 parent 853f56b commit 499fb3f

11 files changed

Lines changed: 81 additions & 31 deletions

‎.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-1c93116e47cab52ea63490f5bca186ed3acda8bbd7f0ce5a320effb9f5b72b1f.yml
3-
openapi_spec_hash: f56204d55bd4bffb6e4d50d6a5d9471a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-7f75f39699c1298d16691b5a58b1312a229b78288fba6e2de4040ba1422e530f.yml
3+
openapi_spec_hash: b3ad781596e4c52fde918cfaae54a5d4
44
config_hash: 920678668dd2da6f8966fbf1b8fde4e2

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def prefetch(
4747
self,
4848
*,
4949
identifier: utility_prefetch_params.Identifier,
50-
type: Literal["brand"],
50+
type: Literal["brand", "styleguide"],
5151
tags: SequenceNotStr[str] | Omit = omit,
5252
timeout_ms: int | Omit = omit,
5353
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -57,17 +57,19 @@ def prefetch(
5757
extra_body: Body | None = None,
5858
timeout: float | httpx.Timeout | None | NotGiven = not_given,
5959
) -> UtilityPrefetchResponse:
60-
"""Signal that you may fetch brand data soon to improve latency.
60+
"""Signal that you may fetch data soon to improve latency.
6161
62-
The type field
63-
selects what to prefetch (currently only 'brand') and identifier carries exactly
64-
one lookup key: a domain, or an email whose domain is extracted and validated
65-
(free email providers and disposable email addresses are not allowed).
62+
The type field selects
63+
what to prefetch ('brand' queues a brand data fetch, 'styleguide' queues a
64+
styleguide extraction) and identifier carries exactly one lookup key: a domain,
65+
or an email whose domain is extracted and validated (free email providers and
66+
disposable email addresses are not allowed).
6667
6768
Args:
68-
identifier: Identifier of the brand to prefetch. Provide exactly one of domain or email.
69+
identifier: Identifier of the target to prefetch. Provide exactly one of domain or email.
6970
70-
type: What to prefetch. Currently only 'brand' is supported.
71+
type: What to prefetch: 'brand' warms the brand data cache, 'styleguide' warms the
72+
styleguide cache.
7173
7274
tags: Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.
7375
@@ -125,7 +127,7 @@ async def prefetch(
125127
self,
126128
*,
127129
identifier: utility_prefetch_params.Identifier,
128-
type: Literal["brand"],
130+
type: Literal["brand", "styleguide"],
129131
tags: SequenceNotStr[str] | Omit = omit,
130132
timeout_ms: int | Omit = omit,
131133
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -135,17 +137,19 @@ async def prefetch(
135137
extra_body: Body | None = None,
136138
timeout: float | httpx.Timeout | None | NotGiven = not_given,
137139
) -> UtilityPrefetchResponse:
138-
"""Signal that you may fetch brand data soon to improve latency.
140+
"""Signal that you may fetch data soon to improve latency.
139141
140-
The type field
141-
selects what to prefetch (currently only 'brand') and identifier carries exactly
142-
one lookup key: a domain, or an email whose domain is extracted and validated
143-
(free email providers and disposable email addresses are not allowed).
142+
The type field selects
143+
what to prefetch ('brand' queues a brand data fetch, 'styleguide' queues a
144+
styleguide extraction) and identifier carries exactly one lookup key: a domain,
145+
or an email whose domain is extracted and validated (free email providers and
146+
disposable email addresses are not allowed).
144147
145148
Args:
146-
identifier: Identifier of the brand to prefetch. Provide exactly one of domain or email.
149+
identifier: Identifier of the target to prefetch. Provide exactly one of domain or email.
147150
148-
type: What to prefetch. Currently only 'brand' is supported.
151+
type: What to prefetch: 'brand' warms the brand data cache, 'styleguide' warms the
152+
styleguide cache.
149153
150154
tags: Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.
151155

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,7 @@ def web_scrape_md(
20222022
exclude_selectors: Optional[SequenceNotStr[str]] | Omit = omit,
20232023
headers: Dict[str, str] | Omit = omit,
20242024
include_frames: Union[bool, Literal["true", "false"]] | Omit = omit,
2025+
include_html: Union[bool, Literal["true", "false"]] | Omit = omit,
20252026
include_images: Union[bool, Literal["true", "false"]] | Omit = omit,
20262027
include_links: Union[bool, Literal["true", "false"]] | Omit = omit,
20272028
include_selectors: Optional[SequenceNotStr[str]] | Omit = omit,
@@ -2094,6 +2095,10 @@ def web_scrape_md(
20942095
20952096
include_frames: When true, the contents of iframes are rendered to Markdown.
20962097
2098+
include_html: When true, the response also includes an `html` field with the page HTML the
2099+
Markdown was converted from — the same body the Scrape HTML endpoint returns for
2100+
the equivalent request.
2101+
20972102
include_images: Include image references in Markdown output
20982103
20992104
include_links: Preserve hyperlinks in Markdown output
@@ -2157,6 +2162,7 @@ def web_scrape_md(
21572162
"exclude_selectors": exclude_selectors,
21582163
"headers": headers,
21592164
"include_frames": include_frames,
2165+
"include_html": include_html,
21602166
"include_images": include_images,
21612167
"include_links": include_links,
21622168
"include_selectors": include_selectors,
@@ -4246,6 +4252,7 @@ async def web_scrape_md(
42464252
exclude_selectors: Optional[SequenceNotStr[str]] | Omit = omit,
42474253
headers: Dict[str, str] | Omit = omit,
42484254
include_frames: Union[bool, Literal["true", "false"]] | Omit = omit,
4255+
include_html: Union[bool, Literal["true", "false"]] | Omit = omit,
42494256
include_images: Union[bool, Literal["true", "false"]] | Omit = omit,
42504257
include_links: Union[bool, Literal["true", "false"]] | Omit = omit,
42514258
include_selectors: Optional[SequenceNotStr[str]] | Omit = omit,
@@ -4318,6 +4325,10 @@ async def web_scrape_md(
43184325
43194326
include_frames: When true, the contents of iframes are rendered to Markdown.
43204327
4328+
include_html: When true, the response also includes an `html` field with the page HTML the
4329+
Markdown was converted from — the same body the Scrape HTML endpoint returns for
4330+
the equivalent request.
4331+
43214332
include_images: Include image references in Markdown output
43224333
43234334
include_links: Preserve hyperlinks in Markdown output
@@ -4381,6 +4392,7 @@ async def web_scrape_md(
43814392
"exclude_selectors": exclude_selectors,
43824393
"headers": headers,
43834394
"include_frames": include_frames,
4395+
"include_html": include_html,
43844396
"include_images": include_images,
43854397
"include_links": include_links,
43864398
"include_selectors": include_selectors,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ class DataOk(BaseModel):
131131
"""URL as submitted, or as discovered by the crawl."""
132132

133133
html: Optional[str] = None
134-
"""Raw page HTML. Present on html batches."""
134+
"""Page HTML.
135+
136+
Present on html batches, and on markdown batches submitted with
137+
`options.includeHTML`.
138+
"""
135139

136140
item_id: Optional[str] = FieldInfo(alias="itemId", default=None)
137141
"""Caller-supplied identifier echoed from submission."""

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ class InputScrapeDataMarkdownOptions(TypedDict, total=False):
329329
Applied after `includeSelectors`, so an element matching both is removed.
330330
"""
331331

332+
include_html: Annotated[bool, PropertyInfo(alias="includeHTML")]
333+
"""
334+
Also include each page's HTML in its result record, as an `html` field alongside
335+
the Markdown.
336+
"""
337+
332338
include_images: Annotated[bool, PropertyInfo(alias="includeImages")]
333339
"""Include image references in the Markdown."""
334340

@@ -1037,6 +1043,12 @@ class InputCrawlDataMarkdownOptions(TypedDict, total=False):
10371043
Applied after `includeSelectors`, so an element matching both is removed.
10381044
"""
10391045

1046+
include_html: Annotated[bool, PropertyInfo(alias="includeHTML")]
1047+
"""
1048+
Also include each page's HTML in its result record, as an `html` field alongside
1049+
the Markdown.
1050+
"""
1051+
10401052
include_images: Annotated[bool, PropertyInfo(alias="includeImages")]
10411053
"""Include image references in the Markdown."""
10421054

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818

1919
class UtilityPrefetchParams(TypedDict, total=False):
2020
identifier: Required[Identifier]
21-
"""Identifier of the brand to prefetch. Provide exactly one of domain or email."""
21+
"""Identifier of the target to prefetch. Provide exactly one of domain or email."""
2222

23-
type: Required[Literal["brand"]]
24-
"""What to prefetch. Currently only 'brand' is supported."""
23+
type: Required[Literal["brand", "styleguide"]]
24+
"""
25+
What to prefetch: 'brand' warms the brand data cache, 'styleguide' warms the
26+
styleguide cache.
27+
"""
2528

2629
tags: SequenceNotStr[str]
2730
"""Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters."""
@@ -35,17 +38,17 @@ class UtilityPrefetchParams(TypedDict, total=False):
3538

3639

3740
class IdentifierUtilityPrefetchDomainIdentifier(TypedDict, total=False):
38-
"""Prefetch brand data by domain."""
41+
"""Prefetch by domain."""
3942

4043
domain: Required[str]
41-
"""Domain name to prefetch brand data for"""
44+
"""Domain name to prefetch data for"""
4245

4346

4447
class IdentifierUtilityPrefetchEmailIdentifier(TypedDict, total=False):
45-
"""Prefetch brand data by email. The domain will be extracted and validated."""
48+
"""Prefetch by email. The domain will be extracted and validated."""
4649

4750
email: Required[str]
48-
"""Email address to prefetch brand data for.
51+
"""Email address to prefetch data for.
4952
5053
The domain will be extracted from the email. Free email providers (gmail.com,
5154
yahoo.com, etc.) and disposable email addresses are not allowed.

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,5 @@ class UtilityPrefetchResponse(BaseModel):
3838
status: Optional[str] = None
3939
"""Status of the response, e.g., 'ok'"""
4040

41-
type: Optional[Literal["brand"]] = None
42-
"""
43-
The type of prefetch that was queued, echoed from the request (currently always
44-
'brand')
45-
"""
41+
type: Optional[Literal["brand", "styleguide"]] = None
42+
"""The type of prefetch that was queued, echoed from the request"""

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ class WebWebScrapeMdParams(TypedDict, total=False):
253253
include_frames: Annotated[Union[bool, Literal["true", "false"]], PropertyInfo(alias="includeFrames")]
254254
"""When true, the contents of iframes are rendered to Markdown."""
255255

256+
include_html: Annotated[Union[bool, Literal["true", "false"]], PropertyInfo(alias="includeHTML")]
257+
"""
258+
When true, the response also includes an `html` field with the page HTML the
259+
Markdown was converted from — the same body the Scrape HTML endpoint returns for
260+
the equivalent request.
261+
"""
262+
256263
include_images: Annotated[Union[bool, Literal["true", "false"]], PropertyInfo(alias="includeImages")]
257264
"""Include image references in Markdown output"""
258265

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ class WebWebScrapeMdResponse(BaseModel):
172172
afterward.
173173
"""
174174

175+
html: Optional[str] = None
176+
"""
177+
Only present when includeHTML=true: the page HTML the Markdown was converted
178+
from — the same body the Scrape HTML endpoint returns for the equivalent
179+
request.
180+
"""
181+
175182
key_metadata: Optional[KeyMetadata] = None
176183
"""Metadata about the API key used for the request.
177184

‎tests/api_resources/test_batch.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ def test_method_submit_with_all_params(self, client: ContextDev) -> None:
282282
"options": {
283283
"country": "de",
284284
"exclude_selectors": ["x"],
285+
"include_html": True,
285286
"include_images": True,
286287
"include_links": True,
287288
"include_selectors": ["x"],
@@ -614,6 +615,7 @@ async def test_method_submit_with_all_params(self, async_client: AsyncContextDev
614615
"options": {
615616
"country": "de",
616617
"exclude_selectors": ["x"],
618+
"include_html": True,
617619
"include_images": True,
618620
"include_links": True,
619621
"include_selectors": ["x"],

0 commit comments

Comments
 (0)