diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6db19b95..4ad3fef3 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.17.0" + ".": "0.18.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 7ac6ab77..e845d92e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 22 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-44904c513baa439f294b23964ea368ad52863e13328980f9cac5a8e78cbb58cb.yml -openapi_spec_hash: 9bb50ca838166fb474d28009a7edbd49 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-e26ac226a3cf6d02380f3df386077414dd424dbf35c7c40e02ba512eff1dff84.yml +openapi_spec_hash: 077166ff05843544fbb4b519200ac9fc config_hash: 70354330f92ce169beabc98696ebb9a3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 71f455f8..1576fe01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.18.0 (2026-05-07) + +Full Changelog: [v0.17.0...v0.18.0](https://github.com/context-dot-dev/context-python-sdk/compare/v0.17.0...v0.18.0) + +### Features + +* **api:** api update ([3649236](https://github.com/context-dot-dev/context-python-sdk/commit/3649236ff759877e620e926e79e6cf22c9412fec)) +* **api:** api update ([0784f70](https://github.com/context-dot-dev/context-python-sdk/commit/0784f706c7fa35b48bff168a66d76f20ad262c9d)) + ## 0.17.0 (2026-05-06) Full Changelog: [v0.16.0...v0.17.0](https://github.com/context-dot-dev/context-python-sdk/compare/v0.16.0...v0.17.0) diff --git a/README.md b/README.md index 5bfddeac..1aa1c6f9 100644 --- a/README.md +++ b/README.md @@ -130,11 +130,10 @@ from context.dev import ContextDev client = ContextDev() -response = client.web.web_scrape_images( - url="https://example.com", - enrichment={}, +response = client.web.screenshot( + viewport={}, ) -print(response.enrichment) +print(response.viewport) ``` ## Handling errors diff --git a/pyproject.toml b/pyproject.toml index c9d2c740..fd4511a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "context.dev" -version = "0.17.0" +version = "0.18.0" description = "The official Python library for the context.dev API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/context/dev/_version.py b/src/context/dev/_version.py index ef66ec44..84297f64 100644 --- a/src/context/dev/_version.py +++ b/src/context/dev/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "context.dev" -__version__ = "0.17.0" # x-release-please-version +__version__ = "0.18.0" # x-release-please-version diff --git a/src/context/dev/resources/ai.py b/src/context/dev/resources/ai.py index 29793804..5e1d231b 100644 --- a/src/context/dev/resources/ai.py +++ b/src/context/dev/resources/ai.py @@ -126,8 +126,9 @@ def extract_product( younger than this many milliseconds. Defaults to 7 days (604800000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh. - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). extra_headers: Send extra headers @@ -183,8 +184,9 @@ def extract_products( max_products: Maximum number of products to extract. - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). extra_headers: Send extra headers @@ -227,8 +229,9 @@ def extract_products( max_products: Maximum number of products to extract. - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). extra_headers: Send extra headers @@ -375,8 +378,9 @@ async def extract_product( younger than this many milliseconds. Defaults to 7 days (604800000 ms) when omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh. - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). extra_headers: Send extra headers @@ -432,8 +436,9 @@ async def extract_products( max_products: Maximum number of products to extract. - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). extra_headers: Send extra headers @@ -476,8 +481,9 @@ async def extract_products( max_products: Maximum number of products to extract. - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). extra_headers: Send extra headers diff --git a/src/context/dev/resources/web.py b/src/context/dev/resources/web.py index 9e1fcf38..43538ca8 100644 --- a/src/context/dev/resources/web.py +++ b/src/context/dev/resources/web.py @@ -180,8 +180,11 @@ def screenshot( direct_url: str | Omit = omit, domain: str | Omit = omit, full_screenshot: Literal["true", "false"] | Omit = omit, + max_age_ms: int | Omit = omit, page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] | Omit = omit, prioritize: Literal["speed", "quality"] | Omit = omit, + timeout_ms: int | Omit = omit, + viewport: web_screenshot_params.Viewport | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -205,6 +208,10 @@ def screenshot( screenshot capturing all content. If 'false' or not provided, takes a viewport screenshot (standard browser view). + max_age_ms: Return a cached screenshot if a prior screenshot for the same parameters exists + and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when + omitted. Max is 30 days (2592000000 ms). Set to 0 to always capture fresh. + page: Optional parameter to specify which page type to screenshot. If provided, the system will scrape the domain's links and use heuristics to find the most appropriate URL for the specified page type (30 supported languages). If not @@ -215,6 +222,12 @@ def screenshot( faster capture with basic quality. If 'quality', optimizes for higher quality with longer wait times. Defaults to 'quality' if not provided. + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + + viewport: Optional browser viewport dimensions for the screenshot. Defaults to 1920x1080. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -235,8 +248,11 @@ def screenshot( "direct_url": direct_url, "domain": domain, "full_screenshot": full_screenshot, + "max_age_ms": max_age_ms, "page": page, "prioritize": prioritize, + "timeout_ms": timeout_ms, + "viewport": viewport, }, web_screenshot_params.WebScreenshotParams, ), @@ -257,6 +273,7 @@ def web_crawl_md( max_pages: int | Omit = omit, parse_pdf: bool | Omit = omit, shorten_base64_images: bool | Omit = omit, + timeout_ms: int | Omit = omit, url_regex: str | Omit = omit, use_main_content_only: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -298,6 +315,10 @@ def web_crawl_md( shorten_base64_images: Truncate base64-encoded image data in the Markdown output + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + url_regex: Regex pattern. Only URLs matching this pattern will be followed and scraped. use_main_content_only: Extract only the main content, stripping headers, footers, sidebars, and @@ -325,6 +346,7 @@ def web_crawl_md( "max_pages": max_pages, "parse_pdf": parse_pdf, "shorten_base64_images": shorten_base64_images, + "timeout_ms": timeout_ms, "url_regex": url_regex, "use_main_content_only": use_main_content_only, }, @@ -343,6 +365,7 @@ def web_scrape_html( include_frames: bool | Omit = omit, max_age_ms: int | Omit = omit, parse_pdf: bool | Omit = omit, + timeout_ms: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -366,6 +389,10 @@ def web_scrape_html( returned wrapped in …. When false, PDF URLs are skipped and a 400 WEBSITE_ACCESS_ERROR is returned. + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -387,6 +414,7 @@ def web_scrape_html( "include_frames": include_frames, "max_age_ms": max_age_ms, "parse_pdf": parse_pdf, + "timeout_ms": timeout_ms, }, web_web_scrape_html_params.WebWebScrapeHTMLParams, ), @@ -400,6 +428,7 @@ def web_scrape_images( url: str, enrichment: web_web_scrape_images_params.Enrichment | Omit = omit, max_age_ms: int | Omit = omit, + timeout_ms: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -422,6 +451,10 @@ def web_scrape_images( max_age_ms: Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1 day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days). + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -442,6 +475,7 @@ def web_scrape_images( "url": url, "enrichment": enrichment, "max_age_ms": max_age_ms, + "timeout_ms": timeout_ms, }, web_web_scrape_images_params.WebWebScrapeImagesParams, ), @@ -459,6 +493,7 @@ def web_scrape_md( max_age_ms: int | Omit = omit, parse_pdf: bool | Omit = omit, shorten_base64_images: bool | Omit = omit, + timeout_ms: int | Omit = omit, use_main_content_only: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -490,6 +525,10 @@ def web_scrape_md( shorten_base64_images: Shorten base64-encoded image data in the Markdown output + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + use_main_content_only: Extract only the main content of the page, excluding headers, footers, sidebars, and navigation @@ -517,6 +556,7 @@ def web_scrape_md( "max_age_ms": max_age_ms, "parse_pdf": parse_pdf, "shorten_base64_images": shorten_base64_images, + "timeout_ms": timeout_ms, "use_main_content_only": use_main_content_only, }, web_web_scrape_md_params.WebWebScrapeMdParams, @@ -530,6 +570,7 @@ def web_scrape_sitemap( *, domain: str, max_links: int | Omit = omit, + timeout_ms: int | Omit = omit, url_regex: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -547,6 +588,10 @@ def web_scrape_sitemap( max_links: Maximum number of links to return from the sitemap crawl. Defaults to 10,000. Minimum is 1, maximum is 100,000. + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + url_regex: Optional RE2-compatible regex pattern. Only URLs matching this pattern are returned and counted against maxLinks. @@ -569,6 +614,7 @@ def web_scrape_sitemap( { "domain": domain, "max_links": max_links, + "timeout_ms": timeout_ms, "url_regex": url_regex, }, web_web_scrape_sitemap_params.WebWebScrapeSitemapParams, @@ -719,8 +765,11 @@ async def screenshot( direct_url: str | Omit = omit, domain: str | Omit = omit, full_screenshot: Literal["true", "false"] | Omit = omit, + max_age_ms: int | Omit = omit, page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] | Omit = omit, prioritize: Literal["speed", "quality"] | Omit = omit, + timeout_ms: int | Omit = omit, + viewport: web_screenshot_params.Viewport | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -744,6 +793,10 @@ async def screenshot( screenshot capturing all content. If 'false' or not provided, takes a viewport screenshot (standard browser view). + max_age_ms: Return a cached screenshot if a prior screenshot for the same parameters exists + and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when + omitted. Max is 30 days (2592000000 ms). Set to 0 to always capture fresh. + page: Optional parameter to specify which page type to screenshot. If provided, the system will scrape the domain's links and use heuristics to find the most appropriate URL for the specified page type (30 supported languages). If not @@ -754,6 +807,12 @@ async def screenshot( faster capture with basic quality. If 'quality', optimizes for higher quality with longer wait times. Defaults to 'quality' if not provided. + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + + viewport: Optional browser viewport dimensions for the screenshot. Defaults to 1920x1080. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -774,8 +833,11 @@ async def screenshot( "direct_url": direct_url, "domain": domain, "full_screenshot": full_screenshot, + "max_age_ms": max_age_ms, "page": page, "prioritize": prioritize, + "timeout_ms": timeout_ms, + "viewport": viewport, }, web_screenshot_params.WebScreenshotParams, ), @@ -796,6 +858,7 @@ async def web_crawl_md( max_pages: int | Omit = omit, parse_pdf: bool | Omit = omit, shorten_base64_images: bool | Omit = omit, + timeout_ms: int | Omit = omit, url_regex: str | Omit = omit, use_main_content_only: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -837,6 +900,10 @@ async def web_crawl_md( shorten_base64_images: Truncate base64-encoded image data in the Markdown output + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + url_regex: Regex pattern. Only URLs matching this pattern will be followed and scraped. use_main_content_only: Extract only the main content, stripping headers, footers, sidebars, and @@ -864,6 +931,7 @@ async def web_crawl_md( "max_pages": max_pages, "parse_pdf": parse_pdf, "shorten_base64_images": shorten_base64_images, + "timeout_ms": timeout_ms, "url_regex": url_regex, "use_main_content_only": use_main_content_only, }, @@ -882,6 +950,7 @@ async def web_scrape_html( include_frames: bool | Omit = omit, max_age_ms: int | Omit = omit, parse_pdf: bool | Omit = omit, + timeout_ms: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -905,6 +974,10 @@ async def web_scrape_html( returned wrapped in …. When false, PDF URLs are skipped and a 400 WEBSITE_ACCESS_ERROR is returned. + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -926,6 +999,7 @@ async def web_scrape_html( "include_frames": include_frames, "max_age_ms": max_age_ms, "parse_pdf": parse_pdf, + "timeout_ms": timeout_ms, }, web_web_scrape_html_params.WebWebScrapeHTMLParams, ), @@ -939,6 +1013,7 @@ async def web_scrape_images( url: str, enrichment: web_web_scrape_images_params.Enrichment | Omit = omit, max_age_ms: int | Omit = omit, + timeout_ms: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -961,6 +1036,10 @@ async def web_scrape_images( max_age_ms: Reuse a cached result this many milliseconds old or newer. Default: 86400000 (1 day). Set to 0 to bypass cache. Maximum: 2592000000 (30 days). + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -981,6 +1060,7 @@ async def web_scrape_images( "url": url, "enrichment": enrichment, "max_age_ms": max_age_ms, + "timeout_ms": timeout_ms, }, web_web_scrape_images_params.WebWebScrapeImagesParams, ), @@ -998,6 +1078,7 @@ async def web_scrape_md( max_age_ms: int | Omit = omit, parse_pdf: bool | Omit = omit, shorten_base64_images: bool | Omit = omit, + timeout_ms: int | Omit = omit, use_main_content_only: bool | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -1029,6 +1110,10 @@ async def web_scrape_md( shorten_base64_images: Shorten base64-encoded image data in the Markdown output + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + use_main_content_only: Extract only the main content of the page, excluding headers, footers, sidebars, and navigation @@ -1056,6 +1141,7 @@ async def web_scrape_md( "max_age_ms": max_age_ms, "parse_pdf": parse_pdf, "shorten_base64_images": shorten_base64_images, + "timeout_ms": timeout_ms, "use_main_content_only": use_main_content_only, }, web_web_scrape_md_params.WebWebScrapeMdParams, @@ -1069,6 +1155,7 @@ async def web_scrape_sitemap( *, domain: str, max_links: int | Omit = omit, + timeout_ms: int | Omit = omit, url_regex: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -1086,6 +1173,10 @@ async def web_scrape_sitemap( max_links: Maximum number of links to return from the sitemap crawl. Defaults to 10,000. Minimum is 1, maximum is 100,000. + timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer + than this value, it will be aborted with a 408 status code. Maximum allowed + value is 300000ms (5 minutes). + url_regex: Optional RE2-compatible regex pattern. Only URLs matching this pattern are returned and counted against maxLinks. @@ -1108,6 +1199,7 @@ async def web_scrape_sitemap( { "domain": domain, "max_links": max_links, + "timeout_ms": timeout_ms, "url_regex": url_regex, }, web_web_scrape_sitemap_params.WebWebScrapeSitemapParams, diff --git a/src/context/dev/types/ai_extract_product_params.py b/src/context/dev/types/ai_extract_product_params.py index 797a1f83..95a16175 100644 --- a/src/context/dev/types/ai_extract_product_params.py +++ b/src/context/dev/types/ai_extract_product_params.py @@ -23,5 +23,6 @@ class AIExtractProductParams(TypedDict, total=False): timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] """Optional timeout in milliseconds for the request. - Maximum allowed value is 300000ms (5 minutes). + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). """ diff --git a/src/context/dev/types/ai_extract_products_params.py b/src/context/dev/types/ai_extract_products_params.py index 62d4a18f..1ca10272 100644 --- a/src/context/dev/types/ai_extract_products_params.py +++ b/src/context/dev/types/ai_extract_products_params.py @@ -27,7 +27,8 @@ class ByDomain(TypedDict, total=False): timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] """Optional timeout in milliseconds for the request. - Maximum allowed value is 300000ms (5 minutes). + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). """ @@ -51,7 +52,8 @@ class ByDirectURL(TypedDict, total=False): timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] """Optional timeout in milliseconds for the request. - Maximum allowed value is 300000ms (5 minutes). + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). """ diff --git a/src/context/dev/types/web_screenshot_params.py b/src/context/dev/types/web_screenshot_params.py index c6de68a8..e901dd62 100644 --- a/src/context/dev/types/web_screenshot_params.py +++ b/src/context/dev/types/web_screenshot_params.py @@ -6,7 +6,7 @@ from .._utils import PropertyInfo -__all__ = ["WebScreenshotParams"] +__all__ = ["WebScreenshotParams", "Viewport"] class WebScreenshotParams(TypedDict, total=False): @@ -31,6 +31,13 @@ class WebScreenshotParams(TypedDict, total=False): provided, takes a viewport screenshot (standard browser view). """ + max_age_ms: Annotated[int, PropertyInfo(alias="maxAgeMs")] + """ + Return a cached screenshot if a prior screenshot for the same parameters exists + and is younger than this many milliseconds. Defaults to 1 day (86400000 ms) when + omitted. Max is 30 days (2592000000 ms). Set to 0 to always capture fresh. + """ + page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] """Optional parameter to specify which page type to screenshot. @@ -47,3 +54,23 @@ class WebScreenshotParams(TypedDict, total=False): optimizes for higher quality with longer wait times. Defaults to 'quality' if not provided. """ + + timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] + """Optional timeout in milliseconds for the request. + + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). + """ + + viewport: Viewport + """Optional browser viewport dimensions for the screenshot. Defaults to 1920x1080.""" + + +class Viewport(TypedDict, total=False): + """Optional browser viewport dimensions for the screenshot. Defaults to 1920x1080.""" + + height: int + """Viewport height in pixels.""" + + width: int + """Viewport width in pixels.""" diff --git a/src/context/dev/types/web_screenshot_response.py b/src/context/dev/types/web_screenshot_response.py index e81a5b23..382707da 100644 --- a/src/context/dev/types/web_screenshot_response.py +++ b/src/context/dev/types/web_screenshot_response.py @@ -17,6 +17,9 @@ class WebScreenshotResponse(BaseModel): domain: Optional[str] = None """The normalized domain that was processed""" + height: Optional[int] = None + """Height in pixels of the returned screenshot image""" + screenshot: Optional[str] = None """Public URL of the uploaded screenshot image""" @@ -25,3 +28,6 @@ class WebScreenshotResponse(BaseModel): status: Optional[str] = None """Status of the response, e.g., 'ok'""" + + width: Optional[int] = None + """Width in pixels of the returned screenshot image""" diff --git a/src/context/dev/types/web_web_crawl_md_params.py b/src/context/dev/types/web_web_crawl_md_params.py index 8e14b0a5..bbc71a58 100644 --- a/src/context/dev/types/web_web_crawl_md_params.py +++ b/src/context/dev/types/web_web_crawl_md_params.py @@ -55,6 +55,13 @@ class WebWebCrawlMdParams(TypedDict, total=False): shorten_base64_images: Annotated[bool, PropertyInfo(alias="shortenBase64Images")] """Truncate base64-encoded image data in the Markdown output""" + timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] + """Optional timeout in milliseconds for the request. + + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). + """ + url_regex: Annotated[str, PropertyInfo(alias="urlRegex")] """Regex pattern. Only URLs matching this pattern will be followed and scraped.""" diff --git a/src/context/dev/types/web_web_scrape_html_params.py b/src/context/dev/types/web_web_scrape_html_params.py index d0eb3a81..6f28cf9e 100644 --- a/src/context/dev/types/web_web_scrape_html_params.py +++ b/src/context/dev/types/web_web_scrape_html_params.py @@ -29,3 +29,10 @@ class WebWebScrapeHTMLParams(TypedDict, total=False): returned wrapped in …. When false, PDF URLs are skipped and a 400 WEBSITE_ACCESS_ERROR is returned. """ + + timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] + """Optional timeout in milliseconds for the request. + + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). + """ diff --git a/src/context/dev/types/web_web_scrape_images_params.py b/src/context/dev/types/web_web_scrape_images_params.py index cd2e4382..189ea2b9 100644 --- a/src/context/dev/types/web_web_scrape_images_params.py +++ b/src/context/dev/types/web_web_scrape_images_params.py @@ -26,6 +26,13 @@ class WebWebScrapeImagesParams(TypedDict, total=False): days). """ + timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] + """Optional timeout in milliseconds for the request. + + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). + """ + class Enrichment(TypedDict, total=False): """ diff --git a/src/context/dev/types/web_web_scrape_md_params.py b/src/context/dev/types/web_web_scrape_md_params.py index 54ba948b..e65c18fe 100644 --- a/src/context/dev/types/web_web_scrape_md_params.py +++ b/src/context/dev/types/web_web_scrape_md_params.py @@ -42,6 +42,13 @@ class WebWebScrapeMdParams(TypedDict, total=False): shorten_base64_images: Annotated[bool, PropertyInfo(alias="shortenBase64Images")] """Shorten base64-encoded image data in the Markdown output""" + timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] + """Optional timeout in milliseconds for the request. + + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). + """ + use_main_content_only: Annotated[bool, PropertyInfo(alias="useMainContentOnly")] """ Extract only the main content of the page, excluding headers, footers, sidebars, diff --git a/src/context/dev/types/web_web_scrape_sitemap_params.py b/src/context/dev/types/web_web_scrape_sitemap_params.py index 3ebe7104..11d025e1 100644 --- a/src/context/dev/types/web_web_scrape_sitemap_params.py +++ b/src/context/dev/types/web_web_scrape_sitemap_params.py @@ -19,6 +19,13 @@ class WebWebScrapeSitemapParams(TypedDict, total=False): Defaults to 10,000. Minimum is 1, maximum is 100,000. """ + timeout_ms: Annotated[int, PropertyInfo(alias="timeoutMS")] + """Optional timeout in milliseconds for the request. + + If the request takes longer than this value, it will be aborted with a 408 + status code. Maximum allowed value is 300000ms (5 minutes). + """ + url_regex: Annotated[str, PropertyInfo(alias="urlRegex")] """Optional RE2-compatible regex pattern. diff --git a/tests/api_resources/test_web.py b/tests/api_resources/test_web.py index dfb17110..0b2f2f4e 100644 --- a/tests/api_resources/test_web.py +++ b/tests/api_resources/test_web.py @@ -115,8 +115,14 @@ def test_method_screenshot_with_all_params(self, client: ContextDev) -> None: direct_url="https://example.com", domain="domain", full_screenshot="true", + max_age_ms=0, page="login", prioritize="speed", + timeout_ms=1000, + viewport={ + "height": 240, + "width": 240, + }, ) assert_matches_type(WebScreenshotResponse, web, path=["response"]) @@ -164,6 +170,7 @@ def test_method_web_crawl_md_with_all_params(self, client: ContextDev) -> None: max_pages=1, parse_pdf=True, shorten_base64_images=True, + timeout_ms=1000, url_regex="^https?://[^/]+/blog/", use_main_content_only=True, ) @@ -211,6 +218,7 @@ def test_method_web_scrape_html_with_all_params(self, client: ContextDev) -> Non include_frames=True, max_age_ms=0, parse_pdf=True, + timeout_ms=1000, ) assert_matches_type(WebWebScrapeHTMLResponse, web, path=["response"]) @@ -260,6 +268,7 @@ def test_method_web_scrape_images_with_all_params(self, client: ContextDev) -> N "resolution": True, }, max_age_ms=0, + timeout_ms=1000, ) assert_matches_type(WebWebScrapeImagesResponse, web, path=["response"]) @@ -308,6 +317,7 @@ def test_method_web_scrape_md_with_all_params(self, client: ContextDev) -> None: max_age_ms=0, parse_pdf=True, shorten_base64_images=True, + timeout_ms=1000, use_main_content_only=True, ) assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) @@ -352,6 +362,7 @@ def test_method_web_scrape_sitemap_with_all_params(self, client: ContextDev) -> web = client.web.web_scrape_sitemap( domain="domain", max_links=1, + timeout_ms=1000, url_regex="^https?://[^/]+/blog/", ) assert_matches_type(WebWebScrapeSitemapResponse, web, path=["response"]) @@ -477,8 +488,14 @@ async def test_method_screenshot_with_all_params(self, async_client: AsyncContex direct_url="https://example.com", domain="domain", full_screenshot="true", + max_age_ms=0, page="login", prioritize="speed", + timeout_ms=1000, + viewport={ + "height": 240, + "width": 240, + }, ) assert_matches_type(WebScreenshotResponse, web, path=["response"]) @@ -526,6 +543,7 @@ async def test_method_web_crawl_md_with_all_params(self, async_client: AsyncCont max_pages=1, parse_pdf=True, shorten_base64_images=True, + timeout_ms=1000, url_regex="^https?://[^/]+/blog/", use_main_content_only=True, ) @@ -573,6 +591,7 @@ async def test_method_web_scrape_html_with_all_params(self, async_client: AsyncC include_frames=True, max_age_ms=0, parse_pdf=True, + timeout_ms=1000, ) assert_matches_type(WebWebScrapeHTMLResponse, web, path=["response"]) @@ -622,6 +641,7 @@ async def test_method_web_scrape_images_with_all_params(self, async_client: Asyn "resolution": True, }, max_age_ms=0, + timeout_ms=1000, ) assert_matches_type(WebWebScrapeImagesResponse, web, path=["response"]) @@ -670,6 +690,7 @@ async def test_method_web_scrape_md_with_all_params(self, async_client: AsyncCon max_age_ms=0, parse_pdf=True, shorten_base64_images=True, + timeout_ms=1000, use_main_content_only=True, ) assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) @@ -714,6 +735,7 @@ async def test_method_web_scrape_sitemap_with_all_params(self, async_client: Asy web = await async_client.web.web_scrape_sitemap( domain="domain", max_links=1, + timeout_ms=1000, url_regex="^https?://[^/]+/blog/", ) assert_matches_type(WebWebScrapeSitemapResponse, web, path=["response"])