Skip to content

Commit 2b2246d

Browse files
feat(api): api update
1 parent ee29b89 commit 2b2246d

7 files changed

Lines changed: 90 additions & 2 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: 25
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-e101766776468a99be4ea6cb65eca390c2930a50708ec8e49a7210f3d1bee144.yml
3-
openapi_spec_hash: 411df107cd6a9e03b051dca5540e4c96
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-9575a58bf027da9ca006bf34d9e24850ef2bbc6de0459b9fff6f26cf62e1d82d.yml
3+
openapi_spec_hash: e68a98dbc0e29b45c42b3517eb554e6c
44
config_hash: f86a4e06ae5ed725aa79d58d7a8dc27c

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ def web_scrape_html(
612612
self,
613613
*,
614614
url: str,
615+
headers: Dict[str, str] | Omit = omit,
615616
include_frames: bool | Omit = omit,
616617
max_age_ms: int | Omit = omit,
617618
pdf: web_web_scrape_html_params.Pdf | Omit = omit,
@@ -630,6 +631,10 @@ def web_scrape_html(
630631
Args:
631632
url: Full URL to scrape (must include http:// or https:// protocol)
632633
634+
headers: Optional outbound HTTP headers forwarded only to the target URL, sent as
635+
deep-object query params such as headers[X-Custom]=value. When provided, caching
636+
is bypassed: the result is neither read from nor written to cache.
637+
633638
include_frames: When true, iframes are rendered inline into the returned HTML.
634639
635640
max_age_ms: Return a cached result if a prior scrape for the same parameters exists and is
@@ -665,6 +670,7 @@ def web_scrape_html(
665670
query=maybe_transform(
666671
{
667672
"url": url,
673+
"headers": headers,
668674
"include_frames": include_frames,
669675
"max_age_ms": max_age_ms,
670676
"pdf": pdf,
@@ -682,6 +688,7 @@ def web_scrape_images(
682688
*,
683689
url: str,
684690
enrichment: web_web_scrape_images_params.Enrichment | Omit = omit,
691+
headers: Dict[str, str] | Omit = omit,
685692
max_age_ms: int | Omit = omit,
686693
timeout_ms: int | Omit = omit,
687694
wait_for_ms: int | Omit = omit,
@@ -704,6 +711,10 @@ def web_scrape_images(
704711
enrichment: Optional per-image processing, sent as deep-object query params such as
705712
enrichment[resolution]=true.
706713
714+
headers: Optional outbound HTTP headers forwarded only to the target URL, sent as
715+
deep-object query params such as headers[X-Custom]=value. When provided, caching
716+
is bypassed: the result is neither read from nor written to cache.
717+
707718
max_age_ms: Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1
708719
day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days).
709720
@@ -733,6 +744,7 @@ def web_scrape_images(
733744
{
734745
"url": url,
735746
"enrichment": enrichment,
747+
"headers": headers,
736748
"max_age_ms": max_age_ms,
737749
"timeout_ms": timeout_ms,
738750
"wait_for_ms": wait_for_ms,
@@ -747,6 +759,7 @@ def web_scrape_md(
747759
self,
748760
*,
749761
url: str,
762+
headers: Dict[str, str] | Omit = omit,
750763
include_frames: bool | Omit = omit,
751764
include_images: bool | Omit = omit,
752765
include_links: bool | Omit = omit,
@@ -770,6 +783,10 @@ def web_scrape_md(
770783
url: Full URL to scrape into LLM usable Markdown (must include http:// or https://
771784
protocol)
772785
786+
headers: Optional outbound HTTP headers forwarded only to the target URL, sent as
787+
deep-object query params such as headers[X-Custom]=value. When provided, caching
788+
is bypassed: the result is neither read from nor written to cache.
789+
773790
include_frames: When true, the contents of iframes are rendered to Markdown.
774791
775792
include_images: Include image references in Markdown output
@@ -813,6 +830,7 @@ def web_scrape_md(
813830
query=maybe_transform(
814831
{
815832
"url": url,
833+
"headers": headers,
816834
"include_frames": include_frames,
817835
"include_images": include_images,
818836
"include_links": include_links,
@@ -833,6 +851,7 @@ def web_scrape_sitemap(
833851
self,
834852
*,
835853
domain: str,
854+
headers: Dict[str, str] | Omit = omit,
836855
max_links: int | Omit = omit,
837856
timeout_ms: int | Omit = omit,
838857
url_regex: str | Omit = omit,
@@ -849,6 +868,10 @@ def web_scrape_sitemap(
849868
Args:
850869
domain: Domain to build a sitemap for
851870
871+
headers: Optional outbound HTTP headers forwarded only to the target URL, sent as
872+
deep-object query params such as headers[X-Custom]=value. When provided, caching
873+
is bypassed: the result is neither read from nor written to cache.
874+
852875
max_links: Maximum number of links to return from the sitemap crawl. Defaults to 10,000.
853876
Minimum is 1, maximum is 100,000.
854877
@@ -877,6 +900,7 @@ def web_scrape_sitemap(
877900
query=maybe_transform(
878901
{
879902
"domain": domain,
903+
"headers": headers,
880904
"max_links": max_links,
881905
"timeout_ms": timeout_ms,
882906
"url_regex": url_regex,
@@ -1454,6 +1478,7 @@ async def web_scrape_html(
14541478
self,
14551479
*,
14561480
url: str,
1481+
headers: Dict[str, str] | Omit = omit,
14571482
include_frames: bool | Omit = omit,
14581483
max_age_ms: int | Omit = omit,
14591484
pdf: web_web_scrape_html_params.Pdf | Omit = omit,
@@ -1472,6 +1497,10 @@ async def web_scrape_html(
14721497
Args:
14731498
url: Full URL to scrape (must include http:// or https:// protocol)
14741499
1500+
headers: Optional outbound HTTP headers forwarded only to the target URL, sent as
1501+
deep-object query params such as headers[X-Custom]=value. When provided, caching
1502+
is bypassed: the result is neither read from nor written to cache.
1503+
14751504
include_frames: When true, iframes are rendered inline into the returned HTML.
14761505
14771506
max_age_ms: Return a cached result if a prior scrape for the same parameters exists and is
@@ -1507,6 +1536,7 @@ async def web_scrape_html(
15071536
query=await async_maybe_transform(
15081537
{
15091538
"url": url,
1539+
"headers": headers,
15101540
"include_frames": include_frames,
15111541
"max_age_ms": max_age_ms,
15121542
"pdf": pdf,
@@ -1524,6 +1554,7 @@ async def web_scrape_images(
15241554
*,
15251555
url: str,
15261556
enrichment: web_web_scrape_images_params.Enrichment | Omit = omit,
1557+
headers: Dict[str, str] | Omit = omit,
15271558
max_age_ms: int | Omit = omit,
15281559
timeout_ms: int | Omit = omit,
15291560
wait_for_ms: int | Omit = omit,
@@ -1546,6 +1577,10 @@ async def web_scrape_images(
15461577
enrichment: Optional per-image processing, sent as deep-object query params such as
15471578
enrichment[resolution]=true.
15481579
1580+
headers: Optional outbound HTTP headers forwarded only to the target URL, sent as
1581+
deep-object query params such as headers[X-Custom]=value. When provided, caching
1582+
is bypassed: the result is neither read from nor written to cache.
1583+
15491584
max_age_ms: Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1
15501585
day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days).
15511586
@@ -1575,6 +1610,7 @@ async def web_scrape_images(
15751610
{
15761611
"url": url,
15771612
"enrichment": enrichment,
1613+
"headers": headers,
15781614
"max_age_ms": max_age_ms,
15791615
"timeout_ms": timeout_ms,
15801616
"wait_for_ms": wait_for_ms,
@@ -1589,6 +1625,7 @@ async def web_scrape_md(
15891625
self,
15901626
*,
15911627
url: str,
1628+
headers: Dict[str, str] | Omit = omit,
15921629
include_frames: bool | Omit = omit,
15931630
include_images: bool | Omit = omit,
15941631
include_links: bool | Omit = omit,
@@ -1612,6 +1649,10 @@ async def web_scrape_md(
16121649
url: Full URL to scrape into LLM usable Markdown (must include http:// or https://
16131650
protocol)
16141651
1652+
headers: Optional outbound HTTP headers forwarded only to the target URL, sent as
1653+
deep-object query params such as headers[X-Custom]=value. When provided, caching
1654+
is bypassed: the result is neither read from nor written to cache.
1655+
16151656
include_frames: When true, the contents of iframes are rendered to Markdown.
16161657
16171658
include_images: Include image references in Markdown output
@@ -1655,6 +1696,7 @@ async def web_scrape_md(
16551696
query=await async_maybe_transform(
16561697
{
16571698
"url": url,
1699+
"headers": headers,
16581700
"include_frames": include_frames,
16591701
"include_images": include_images,
16601702
"include_links": include_links,
@@ -1675,6 +1717,7 @@ async def web_scrape_sitemap(
16751717
self,
16761718
*,
16771719
domain: str,
1720+
headers: Dict[str, str] | Omit = omit,
16781721
max_links: int | Omit = omit,
16791722
timeout_ms: int | Omit = omit,
16801723
url_regex: str | Omit = omit,
@@ -1691,6 +1734,10 @@ async def web_scrape_sitemap(
16911734
Args:
16921735
domain: Domain to build a sitemap for
16931736
1737+
headers: Optional outbound HTTP headers forwarded only to the target URL, sent as
1738+
deep-object query params such as headers[X-Custom]=value. When provided, caching
1739+
is bypassed: the result is neither read from nor written to cache.
1740+
16941741
max_links: Maximum number of links to return from the sitemap crawl. Defaults to 10,000.
16951742
Minimum is 1, maximum is 100,000.
16961743
@@ -1719,6 +1766,7 @@ async def web_scrape_sitemap(
17191766
query=await async_maybe_transform(
17201767
{
17211768
"domain": domain,
1769+
"headers": headers,
17221770
"max_links": max_links,
17231771
"timeout_ms": timeout_ms,
17241772
"url_regex": url_regex,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Dict
56
from typing_extensions import Required, Annotated, TypedDict
67

78
from .._utils import PropertyInfo
@@ -13,6 +14,13 @@ class WebWebScrapeHTMLParams(TypedDict, total=False):
1314
url: Required[str]
1415
"""Full URL to scrape (must include http:// or https:// protocol)"""
1516

17+
headers: Dict[str, str]
18+
"""
19+
Optional outbound HTTP headers forwarded only to the target URL, sent as
20+
deep-object query params such as headers[X-Custom]=value. When provided, caching
21+
is bypassed: the result is neither read from nor written to cache.
22+
"""
23+
1624
include_frames: Annotated[bool, PropertyInfo(alias="includeFrames")]
1725
"""When true, iframes are rendered inline into the returned HTML."""
1826

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Dict
56
from typing_extensions import Required, Annotated, TypedDict
67

78
from .._utils import PropertyInfo
@@ -19,6 +20,13 @@ class WebWebScrapeImagesParams(TypedDict, total=False):
1920
enrichment[resolution]=true.
2021
"""
2122

23+
headers: Dict[str, str]
24+
"""
25+
Optional outbound HTTP headers forwarded only to the target URL, sent as
26+
deep-object query params such as headers[X-Custom]=value. When provided, caching
27+
is bypassed: the result is neither read from nor written to cache.
28+
"""
29+
2230
max_age_ms: Annotated[int, PropertyInfo(alias="maxAgeMs")]
2331
"""Reuse a cached result this many milliseconds old or newer.
2432

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Dict
56
from typing_extensions import Required, Annotated, TypedDict
67

78
from .._utils import PropertyInfo
@@ -16,6 +17,13 @@ class WebWebScrapeMdParams(TypedDict, total=False):
1617
protocol)
1718
"""
1819

20+
headers: Dict[str, str]
21+
"""
22+
Optional outbound HTTP headers forwarded only to the target URL, sent as
23+
deep-object query params such as headers[X-Custom]=value. When provided, caching
24+
is bypassed: the result is neither read from nor written to cache.
25+
"""
26+
1927
include_frames: Annotated[bool, PropertyInfo(alias="includeFrames")]
2028
"""When true, the contents of iframes are rendered to Markdown."""
2129

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Dict
56
from typing_extensions import Required, Annotated, TypedDict
67

78
from .._utils import PropertyInfo
@@ -13,6 +14,13 @@ class WebWebScrapeSitemapParams(TypedDict, total=False):
1314
domain: Required[str]
1415
"""Domain to build a sitemap for"""
1516

17+
headers: Dict[str, str]
18+
"""
19+
Optional outbound HTTP headers forwarded only to the target URL, sent as
20+
deep-object query params such as headers[X-Custom]=value. When provided, caching
21+
is bypassed: the result is neither read from nor written to cache.
22+
"""
23+
1624
max_links: Annotated[int, PropertyInfo(alias="maxLinks")]
1725
"""Maximum number of links to return from the sitemap crawl.
1826

‎tests/api_resources/test_web.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def test_method_web_scrape_html(self, client: ContextDev) -> None:
413413
def test_method_web_scrape_html_with_all_params(self, client: ContextDev) -> None:
414414
web = client.web.web_scrape_html(
415415
url="https://example.com",
416+
headers={"foo": "J!"},
416417
include_frames=True,
417418
max_age_ms=0,
418419
pdf={
@@ -470,6 +471,7 @@ def test_method_web_scrape_images_with_all_params(self, client: ContextDev) -> N
470471
"max_time_per_ms": 1,
471472
"resolution": True,
472473
},
474+
headers={"foo": "J!"},
473475
max_age_ms=0,
474476
timeout_ms=1000,
475477
wait_for_ms=0,
@@ -515,6 +517,7 @@ def test_method_web_scrape_md(self, client: ContextDev) -> None:
515517
def test_method_web_scrape_md_with_all_params(self, client: ContextDev) -> None:
516518
web = client.web.web_scrape_md(
517519
url="https://example.com",
520+
headers={"foo": "J!"},
518521
include_frames=True,
519522
include_images=True,
520523
include_links=True,
@@ -570,6 +573,7 @@ def test_method_web_scrape_sitemap(self, client: ContextDev) -> None:
570573
def test_method_web_scrape_sitemap_with_all_params(self, client: ContextDev) -> None:
571574
web = client.web.web_scrape_sitemap(
572575
domain="domain",
576+
headers={"foo": "J!"},
573577
max_links=1,
574578
timeout_ms=1000,
575579
url_regex="^https?://[^/]+/blog/",
@@ -992,6 +996,7 @@ async def test_method_web_scrape_html(self, async_client: AsyncContextDev) -> No
992996
async def test_method_web_scrape_html_with_all_params(self, async_client: AsyncContextDev) -> None:
993997
web = await async_client.web.web_scrape_html(
994998
url="https://example.com",
999+
headers={"foo": "J!"},
9951000
include_frames=True,
9961001
max_age_ms=0,
9971002
pdf={
@@ -1049,6 +1054,7 @@ async def test_method_web_scrape_images_with_all_params(self, async_client: Asyn
10491054
"max_time_per_ms": 1,
10501055
"resolution": True,
10511056
},
1057+
headers={"foo": "J!"},
10521058
max_age_ms=0,
10531059
timeout_ms=1000,
10541060
wait_for_ms=0,
@@ -1094,6 +1100,7 @@ async def test_method_web_scrape_md(self, async_client: AsyncContextDev) -> None
10941100
async def test_method_web_scrape_md_with_all_params(self, async_client: AsyncContextDev) -> None:
10951101
web = await async_client.web.web_scrape_md(
10961102
url="https://example.com",
1103+
headers={"foo": "J!"},
10971104
include_frames=True,
10981105
include_images=True,
10991106
include_links=True,
@@ -1149,6 +1156,7 @@ async def test_method_web_scrape_sitemap(self, async_client: AsyncContextDev) ->
11491156
async def test_method_web_scrape_sitemap_with_all_params(self, async_client: AsyncContextDev) -> None:
11501157
web = await async_client.web.web_scrape_sitemap(
11511158
domain="domain",
1159+
headers={"foo": "J!"},
11521160
max_links=1,
11531161
timeout_ms=1000,
11541162
url_regex="^https?://[^/]+/blog/",

0 commit comments

Comments
 (0)