Skip to content

Commit 51e02cd

Browse files
feat(api): api update
1 parent 57c6a22 commit 51e02cd

4 files changed

Lines changed: 45 additions & 31 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: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-795a81d4c022b9fa5ca31d453fb55d7b75c0b2424f9f4bda5a75762cbb1f9418.yml
3-
openapi_spec_hash: eeb4b6592caa69691a5acfa24b571daa
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-5ee7a321f8e01d2678d56277f011f71294c2b8ac4d0cff0bda412362c0d9cf73.yml
3+
openapi_spec_hash: bf5d57e3bddb6975770cf85c267b5035
44
config_hash: 682b89b02a20f5d1c13e2c91ecbcf5ce

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def with_streaming_response(self) -> WebResourceWithStreamingResponse:
5858
def screenshot(
5959
self,
6060
*,
61-
domain: str,
61+
direct_url: str | Omit = omit,
62+
domain: str | Omit = omit,
6263
full_screenshot: Literal["true", "false"] | Omit = omit,
6364
page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] | Omit = omit,
6465
prioritize: Literal["speed", "quality"] | Omit = omit,
@@ -73,10 +74,15 @@ def screenshot(
7374
7475
Supports both viewport (standard browser
7576
view) and full-page screenshots. Can also screenshot specific page types (login,
76-
pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to
77-
the uploaded screenshot image hosted on our CDN.
77+
pricing, etc.) by using heuristics to find the appropriate URL. Either 'domain'
78+
or 'directUrl' must be provided as a query parameter, but not both. Returns a
79+
URL to the uploaded screenshot image hosted on our CDN.
7880
7981
Args:
82+
direct_url: A specific URL to screenshot directly, bypassing domain resolution (e.g.,
83+
'https://example.com/pricing'). When provided, the screenshot is taken of this
84+
exact URL.
85+
8086
domain: Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The
8187
domain will be automatically normalized and validated.
8288
@@ -87,7 +93,8 @@ def screenshot(
8793
page: Optional parameter to specify which page type to screenshot. If provided, the
8894
system will scrape the domain's links and use heuristics to find the most
8995
appropriate URL for the specified page type (30 supported languages). If not
90-
provided, screenshots the main domain landing page.
96+
provided, screenshots the main domain landing page. Only applicable when using
97+
'domain', not 'directUrl'.
9198
9299
prioritize: Optional parameter to prioritize screenshot capture. If 'speed', optimizes for
93100
faster capture with basic quality. If 'quality', optimizes for higher quality
@@ -110,6 +117,7 @@ def screenshot(
110117
timeout=timeout,
111118
query=maybe_transform(
112119
{
120+
"direct_url": direct_url,
113121
"domain": domain,
114122
"full_screenshot": full_screenshot,
115123
"page": page,
@@ -409,7 +417,8 @@ def with_streaming_response(self) -> AsyncWebResourceWithStreamingResponse:
409417
async def screenshot(
410418
self,
411419
*,
412-
domain: str,
420+
direct_url: str | Omit = omit,
421+
domain: str | Omit = omit,
413422
full_screenshot: Literal["true", "false"] | Omit = omit,
414423
page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] | Omit = omit,
415424
prioritize: Literal["speed", "quality"] | Omit = omit,
@@ -424,10 +433,15 @@ async def screenshot(
424433
425434
Supports both viewport (standard browser
426435
view) and full-page screenshots. Can also screenshot specific page types (login,
427-
pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to
428-
the uploaded screenshot image hosted on our CDN.
436+
pricing, etc.) by using heuristics to find the appropriate URL. Either 'domain'
437+
or 'directUrl' must be provided as a query parameter, but not both. Returns a
438+
URL to the uploaded screenshot image hosted on our CDN.
429439
430440
Args:
441+
direct_url: A specific URL to screenshot directly, bypassing domain resolution (e.g.,
442+
'https://example.com/pricing'). When provided, the screenshot is taken of this
443+
exact URL.
444+
431445
domain: Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The
432446
domain will be automatically normalized and validated.
433447
@@ -438,7 +452,8 @@ async def screenshot(
438452
page: Optional parameter to specify which page type to screenshot. If provided, the
439453
system will scrape the domain's links and use heuristics to find the most
440454
appropriate URL for the specified page type (30 supported languages). If not
441-
provided, screenshots the main domain landing page.
455+
provided, screenshots the main domain landing page. Only applicable when using
456+
'domain', not 'directUrl'.
442457
443458
prioritize: Optional parameter to prioritize screenshot capture. If 'speed', optimizes for
444459
faster capture with basic quality. If 'quality', optimizes for higher quality
@@ -461,6 +476,7 @@ async def screenshot(
461476
timeout=timeout,
462477
query=await async_maybe_transform(
463478
{
479+
"direct_url": direct_url,
464480
"domain": domain,
465481
"full_screenshot": full_screenshot,
466482
"page": page,

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Literal, Required, Annotated, TypedDict
5+
from typing_extensions import Literal, Annotated, TypedDict
66

77
from .._utils import PropertyInfo
88

99
__all__ = ["WebScreenshotParams"]
1010

1111

1212
class WebScreenshotParams(TypedDict, total=False):
13-
domain: Required[str]
13+
direct_url: Annotated[str, PropertyInfo(alias="directUrl")]
14+
"""
15+
A specific URL to screenshot directly, bypassing domain resolution (e.g.,
16+
'https://example.com/pricing'). When provided, the screenshot is taken of this
17+
exact URL.
18+
"""
19+
20+
domain: str
1421
"""Domain name to take screenshot of (e.g., 'example.com', 'google.com').
1522
1623
The domain will be automatically normalized and validated.
@@ -28,7 +35,8 @@ class WebScreenshotParams(TypedDict, total=False):
2835
2936
If provided, the system will scrape the domain's links and use heuristics to
3037
find the most appropriate URL for the specified page type (30 supported
31-
languages). If not provided, screenshots the main domain landing page.
38+
languages). If not provided, screenshots the main domain landing page. Only
39+
applicable when using 'domain', not 'directUrl'.
3240
"""
3341

3442
prioritize: Literal["speed", "quality"]

‎tests/api_resources/test_web.py‎

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ class TestWeb:
2727
@pytest.mark.skip(reason="Mock server tests are disabled")
2828
@parametrize
2929
def test_method_screenshot(self, client: ContextDev) -> None:
30-
web = client.web.screenshot(
31-
domain="domain",
32-
)
30+
web = client.web.screenshot()
3331
assert_matches_type(WebScreenshotResponse, web, path=["response"])
3432

3533
@pytest.mark.skip(reason="Mock server tests are disabled")
3634
@parametrize
3735
def test_method_screenshot_with_all_params(self, client: ContextDev) -> None:
3836
web = client.web.screenshot(
37+
direct_url="https://example.com",
3938
domain="domain",
4039
full_screenshot="true",
4140
page="login",
@@ -46,9 +45,7 @@ def test_method_screenshot_with_all_params(self, client: ContextDev) -> None:
4645
@pytest.mark.skip(reason="Mock server tests are disabled")
4746
@parametrize
4847
def test_raw_response_screenshot(self, client: ContextDev) -> None:
49-
response = client.web.with_raw_response.screenshot(
50-
domain="domain",
51-
)
48+
response = client.web.with_raw_response.screenshot()
5249

5350
assert response.is_closed is True
5451
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -58,9 +55,7 @@ def test_raw_response_screenshot(self, client: ContextDev) -> None:
5855
@pytest.mark.skip(reason="Mock server tests are disabled")
5956
@parametrize
6057
def test_streaming_response_screenshot(self, client: ContextDev) -> None:
61-
with client.web.with_streaming_response.screenshot(
62-
domain="domain",
63-
) as response:
58+
with client.web.with_streaming_response.screenshot() as response:
6459
assert not response.is_closed
6560
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
6661

@@ -285,15 +280,14 @@ class TestAsyncWeb:
285280
@pytest.mark.skip(reason="Mock server tests are disabled")
286281
@parametrize
287282
async def test_method_screenshot(self, async_client: AsyncContextDev) -> None:
288-
web = await async_client.web.screenshot(
289-
domain="domain",
290-
)
283+
web = await async_client.web.screenshot()
291284
assert_matches_type(WebScreenshotResponse, web, path=["response"])
292285

293286
@pytest.mark.skip(reason="Mock server tests are disabled")
294287
@parametrize
295288
async def test_method_screenshot_with_all_params(self, async_client: AsyncContextDev) -> None:
296289
web = await async_client.web.screenshot(
290+
direct_url="https://example.com",
297291
domain="domain",
298292
full_screenshot="true",
299293
page="login",
@@ -304,9 +298,7 @@ async def test_method_screenshot_with_all_params(self, async_client: AsyncContex
304298
@pytest.mark.skip(reason="Mock server tests are disabled")
305299
@parametrize
306300
async def test_raw_response_screenshot(self, async_client: AsyncContextDev) -> None:
307-
response = await async_client.web.with_raw_response.screenshot(
308-
domain="domain",
309-
)
301+
response = await async_client.web.with_raw_response.screenshot()
310302

311303
assert response.is_closed is True
312304
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -316,9 +308,7 @@ async def test_raw_response_screenshot(self, async_client: AsyncContextDev) -> N
316308
@pytest.mark.skip(reason="Mock server tests are disabled")
317309
@parametrize
318310
async def test_streaming_response_screenshot(self, async_client: AsyncContextDev) -> None:
319-
async with async_client.web.with_streaming_response.screenshot(
320-
domain="domain",
321-
) as response:
311+
async with async_client.web.with_streaming_response.screenshot() as response:
322312
assert not response.is_closed
323313
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
324314

0 commit comments

Comments
 (0)