diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d2ac0b..10f3091 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.2.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index bc49c22..c4d3922 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 20 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-c5d5abb4b31f6e352e3e02b47120e3f444377c1c564f141ebe0988b86ba5932e.yml -openapi_spec_hash: 8ef4803fbe33ae6472a4b8f660be7921 -config_hash: a144af00e5e74176674d0ea954cc02c5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-c2e94e0c758b1aaba120c2a4231842fff0a120acc471fe24c7a81221e13a0482.yml +openapi_spec_hash: aabc231b46b1ca3375882f96c378c665 +config_hash: ab5135cc119f83ae2821f9445ed99d16 diff --git a/CHANGELOG.md b/CHANGELOG.md index c550c0f..5ff88eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 0.2.0 (2026-03-18) + +Full Changelog: [v0.1.0...v0.2.0](https://github.com/brand-dot-dev/context-python-sdk/compare/v0.1.0...v0.2.0) + +### Features + +* **api:** api update ([c4538b4](https://github.com/brand-dot-dev/context-python-sdk/commit/c4538b459e6dcee56fb4b2ca85c94db4589d4318)) +* **api:** manual updates ([8304083](https://github.com/brand-dot-dev/context-python-sdk/commit/830408303450a4b85dfd444a2c4790cc8fecf292)) +* **api:** manual updates ([3285d21](https://github.com/brand-dot-dev/context-python-sdk/commit/3285d21cae790e5529ba6fcd7a79612ffc7e7738)) + ## 0.1.0 (2026-03-18) Full Changelog: [v0.0.3...v0.1.0](https://github.com/brand-dot-dev/context-python-sdk/compare/v0.0.3...v0.1.0) diff --git a/README.md b/README.md index b218d59..83a846f 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ from context.dev import ContextDev client = ContextDev() -response = client.brand.ai_query( +response = client.ai.ai_query( data_to_extract=[ { "datapoint_description": "datapoint_description", diff --git a/api.md b/api.md index 5e27158..34b0ee0 100644 --- a/api.md +++ b/api.md @@ -1,3 +1,52 @@ +# Web + +Types: + +```python +from context.dev.types import ( + WebScreenshotResponse, + WebWebScrapeHTMLResponse, + WebWebScrapeImagesResponse, + WebWebScrapeMdResponse, + WebWebScrapeSitemapResponse, +) +``` + +Methods: + +- client.web.screenshot(\*\*params) -> WebScreenshotResponse +- client.web.web_scrape_html(\*\*params) -> WebWebScrapeHTMLResponse +- client.web.web_scrape_images(\*\*params) -> WebWebScrapeImagesResponse +- client.web.web_scrape_md(\*\*params) -> WebWebScrapeMdResponse +- client.web.web_scrape_sitemap(\*\*params) -> WebWebScrapeSitemapResponse + +# AI + +Types: + +```python +from context.dev.types import AIAIQueryResponse, AIExtractProductResponse, AIExtractProductsResponse +``` + +Methods: + +- client.ai.ai_query(\*\*params) -> AIAIQueryResponse +- client.ai.extract_product(\*\*params) -> AIExtractProductResponse +- client.ai.extract_products(\*\*params) -> AIExtractProductsResponse + +# Style + +Types: + +```python +from context.dev.types import StyleExtractFontsResponse, StyleExtractStyleguideResponse +``` + +Methods: + +- client.style.extract_fonts(\*\*params) -> StyleExtractFontsResponse +- client.style.extract_styleguide(\*\*params) -> StyleExtractStyleguideResponse + # Brand Types: @@ -5,47 +54,46 @@ Types: ```python from context.dev.types import ( BrandRetrieveResponse, - BrandAIProductResponse, - BrandAIProductsResponse, - BrandAIQueryResponse, - BrandFontsResponse, BrandIdentifyFromTransactionResponse, - BrandPrefetchResponse, - BrandPrefetchByEmailResponse, BrandRetrieveByEmailResponse, BrandRetrieveByIsinResponse, BrandRetrieveByNameResponse, BrandRetrieveByTickerResponse, - BrandRetrieveNaicsResponse, BrandRetrieveSimplifiedResponse, - BrandScreenshotResponse, - BrandStyleguideResponse, - BrandWebScrapeHTMLResponse, - BrandWebScrapeImagesResponse, - BrandWebScrapeMdResponse, - BrandWebScrapeSitemapResponse, ) ``` Methods: - client.brand.retrieve(\*\*params) -> BrandRetrieveResponse -- client.brand.ai_product(\*\*params) -> BrandAIProductResponse -- client.brand.ai_products(\*\*params) -> BrandAIProductsResponse -- client.brand.ai_query(\*\*params) -> BrandAIQueryResponse -- client.brand.fonts(\*\*params) -> BrandFontsResponse - client.brand.identify_from_transaction(\*\*params) -> BrandIdentifyFromTransactionResponse -- client.brand.prefetch(\*\*params) -> BrandPrefetchResponse -- client.brand.prefetch_by_email(\*\*params) -> BrandPrefetchByEmailResponse - client.brand.retrieve_by_email(\*\*params) -> BrandRetrieveByEmailResponse - client.brand.retrieve_by_isin(\*\*params) -> BrandRetrieveByIsinResponse - client.brand.retrieve_by_name(\*\*params) -> BrandRetrieveByNameResponse - client.brand.retrieve_by_ticker(\*\*params) -> BrandRetrieveByTickerResponse -- client.brand.retrieve_naics(\*\*params) -> BrandRetrieveNaicsResponse - client.brand.retrieve_simplified(\*\*params) -> BrandRetrieveSimplifiedResponse -- client.brand.screenshot(\*\*params) -> BrandScreenshotResponse -- client.brand.styleguide(\*\*params) -> BrandStyleguideResponse -- client.brand.web_scrape_html(\*\*params) -> BrandWebScrapeHTMLResponse -- client.brand.web_scrape_images(\*\*params) -> BrandWebScrapeImagesResponse -- client.brand.web_scrape_md(\*\*params) -> BrandWebScrapeMdResponse -- client.brand.web_scrape_sitemap(\*\*params) -> BrandWebScrapeSitemapResponse + +# Industry + +Types: + +```python +from context.dev.types import IndustryRetrieveNaicsResponse +``` + +Methods: + +- client.industry.retrieve_naics(\*\*params) -> IndustryRetrieveNaicsResponse + +# Utility + +Types: + +```python +from context.dev.types import UtilityPrefetchResponse, UtilityPrefetchByEmailResponse +``` + +Methods: + +- client.utility.prefetch(\*\*params) -> UtilityPrefetchResponse +- client.utility.prefetch_by_email(\*\*params) -> UtilityPrefetchByEmailResponse diff --git a/pyproject.toml b/pyproject.toml index 767433b..8c72792 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "context.dev" -version = "0.1.0" +version = "0.2.0" description = "The official Python library for the context.dev API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/context/dev/_client.py b/src/context/dev/_client.py index cd61b93..06cee7f 100644 --- a/src/context/dev/_client.py +++ b/src/context/dev/_client.py @@ -31,8 +31,13 @@ ) if TYPE_CHECKING: - from .resources import brand + from .resources import ai, web, brand, style, utility, industry + from .resources.ai import AIResource, AsyncAIResource + from .resources.web import WebResource, AsyncWebResource from .resources.brand import BrandResource, AsyncBrandResource + from .resources.style import StyleResource, AsyncStyleResource + from .resources.utility import UtilityResource, AsyncUtilityResource + from .resources.industry import IndustryResource, AsyncIndustryResource __all__ = [ "Timeout", @@ -101,12 +106,42 @@ def __init__( _strict_response_validation=_strict_response_validation, ) + @cached_property + def web(self) -> WebResource: + from .resources.web import WebResource + + return WebResource(self) + + @cached_property + def ai(self) -> AIResource: + from .resources.ai import AIResource + + return AIResource(self) + + @cached_property + def style(self) -> StyleResource: + from .resources.style import StyleResource + + return StyleResource(self) + @cached_property def brand(self) -> BrandResource: from .resources.brand import BrandResource return BrandResource(self) + @cached_property + def industry(self) -> IndustryResource: + from .resources.industry import IndustryResource + + return IndustryResource(self) + + @cached_property + def utility(self) -> UtilityResource: + from .resources.utility import UtilityResource + + return UtilityResource(self) + @cached_property def with_raw_response(self) -> ContextDevWithRawResponse: return ContextDevWithRawResponse(self) @@ -275,12 +310,42 @@ def __init__( _strict_response_validation=_strict_response_validation, ) + @cached_property + def web(self) -> AsyncWebResource: + from .resources.web import AsyncWebResource + + return AsyncWebResource(self) + + @cached_property + def ai(self) -> AsyncAIResource: + from .resources.ai import AsyncAIResource + + return AsyncAIResource(self) + + @cached_property + def style(self) -> AsyncStyleResource: + from .resources.style import AsyncStyleResource + + return AsyncStyleResource(self) + @cached_property def brand(self) -> AsyncBrandResource: from .resources.brand import AsyncBrandResource return AsyncBrandResource(self) + @cached_property + def industry(self) -> AsyncIndustryResource: + from .resources.industry import AsyncIndustryResource + + return AsyncIndustryResource(self) + + @cached_property + def utility(self) -> AsyncUtilityResource: + from .resources.utility import AsyncUtilityResource + + return AsyncUtilityResource(self) + @cached_property def with_raw_response(self) -> AsyncContextDevWithRawResponse: return AsyncContextDevWithRawResponse(self) @@ -400,12 +465,42 @@ class ContextDevWithRawResponse: def __init__(self, client: ContextDev) -> None: self._client = client + @cached_property + def web(self) -> web.WebResourceWithRawResponse: + from .resources.web import WebResourceWithRawResponse + + return WebResourceWithRawResponse(self._client.web) + + @cached_property + def ai(self) -> ai.AIResourceWithRawResponse: + from .resources.ai import AIResourceWithRawResponse + + return AIResourceWithRawResponse(self._client.ai) + + @cached_property + def style(self) -> style.StyleResourceWithRawResponse: + from .resources.style import StyleResourceWithRawResponse + + return StyleResourceWithRawResponse(self._client.style) + @cached_property def brand(self) -> brand.BrandResourceWithRawResponse: from .resources.brand import BrandResourceWithRawResponse return BrandResourceWithRawResponse(self._client.brand) + @cached_property + def industry(self) -> industry.IndustryResourceWithRawResponse: + from .resources.industry import IndustryResourceWithRawResponse + + return IndustryResourceWithRawResponse(self._client.industry) + + @cached_property + def utility(self) -> utility.UtilityResourceWithRawResponse: + from .resources.utility import UtilityResourceWithRawResponse + + return UtilityResourceWithRawResponse(self._client.utility) + class AsyncContextDevWithRawResponse: _client: AsyncContextDev @@ -413,12 +508,42 @@ class AsyncContextDevWithRawResponse: def __init__(self, client: AsyncContextDev) -> None: self._client = client + @cached_property + def web(self) -> web.AsyncWebResourceWithRawResponse: + from .resources.web import AsyncWebResourceWithRawResponse + + return AsyncWebResourceWithRawResponse(self._client.web) + + @cached_property + def ai(self) -> ai.AsyncAIResourceWithRawResponse: + from .resources.ai import AsyncAIResourceWithRawResponse + + return AsyncAIResourceWithRawResponse(self._client.ai) + + @cached_property + def style(self) -> style.AsyncStyleResourceWithRawResponse: + from .resources.style import AsyncStyleResourceWithRawResponse + + return AsyncStyleResourceWithRawResponse(self._client.style) + @cached_property def brand(self) -> brand.AsyncBrandResourceWithRawResponse: from .resources.brand import AsyncBrandResourceWithRawResponse return AsyncBrandResourceWithRawResponse(self._client.brand) + @cached_property + def industry(self) -> industry.AsyncIndustryResourceWithRawResponse: + from .resources.industry import AsyncIndustryResourceWithRawResponse + + return AsyncIndustryResourceWithRawResponse(self._client.industry) + + @cached_property + def utility(self) -> utility.AsyncUtilityResourceWithRawResponse: + from .resources.utility import AsyncUtilityResourceWithRawResponse + + return AsyncUtilityResourceWithRawResponse(self._client.utility) + class ContextDevWithStreamedResponse: _client: ContextDev @@ -426,12 +551,42 @@ class ContextDevWithStreamedResponse: def __init__(self, client: ContextDev) -> None: self._client = client + @cached_property + def web(self) -> web.WebResourceWithStreamingResponse: + from .resources.web import WebResourceWithStreamingResponse + + return WebResourceWithStreamingResponse(self._client.web) + + @cached_property + def ai(self) -> ai.AIResourceWithStreamingResponse: + from .resources.ai import AIResourceWithStreamingResponse + + return AIResourceWithStreamingResponse(self._client.ai) + + @cached_property + def style(self) -> style.StyleResourceWithStreamingResponse: + from .resources.style import StyleResourceWithStreamingResponse + + return StyleResourceWithStreamingResponse(self._client.style) + @cached_property def brand(self) -> brand.BrandResourceWithStreamingResponse: from .resources.brand import BrandResourceWithStreamingResponse return BrandResourceWithStreamingResponse(self._client.brand) + @cached_property + def industry(self) -> industry.IndustryResourceWithStreamingResponse: + from .resources.industry import IndustryResourceWithStreamingResponse + + return IndustryResourceWithStreamingResponse(self._client.industry) + + @cached_property + def utility(self) -> utility.UtilityResourceWithStreamingResponse: + from .resources.utility import UtilityResourceWithStreamingResponse + + return UtilityResourceWithStreamingResponse(self._client.utility) + class AsyncContextDevWithStreamedResponse: _client: AsyncContextDev @@ -439,12 +594,42 @@ class AsyncContextDevWithStreamedResponse: def __init__(self, client: AsyncContextDev) -> None: self._client = client + @cached_property + def web(self) -> web.AsyncWebResourceWithStreamingResponse: + from .resources.web import AsyncWebResourceWithStreamingResponse + + return AsyncWebResourceWithStreamingResponse(self._client.web) + + @cached_property + def ai(self) -> ai.AsyncAIResourceWithStreamingResponse: + from .resources.ai import AsyncAIResourceWithStreamingResponse + + return AsyncAIResourceWithStreamingResponse(self._client.ai) + + @cached_property + def style(self) -> style.AsyncStyleResourceWithStreamingResponse: + from .resources.style import AsyncStyleResourceWithStreamingResponse + + return AsyncStyleResourceWithStreamingResponse(self._client.style) + @cached_property def brand(self) -> brand.AsyncBrandResourceWithStreamingResponse: from .resources.brand import AsyncBrandResourceWithStreamingResponse return AsyncBrandResourceWithStreamingResponse(self._client.brand) + @cached_property + def industry(self) -> industry.AsyncIndustryResourceWithStreamingResponse: + from .resources.industry import AsyncIndustryResourceWithStreamingResponse + + return AsyncIndustryResourceWithStreamingResponse(self._client.industry) + + @cached_property + def utility(self) -> utility.AsyncUtilityResourceWithStreamingResponse: + from .resources.utility import AsyncUtilityResourceWithStreamingResponse + + return AsyncUtilityResourceWithStreamingResponse(self._client.utility) + Client = ContextDev diff --git a/src/context/dev/_version.py b/src/context/dev/_version.py index f96f8e2..b3d54a5 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.1.0" # x-release-please-version +__version__ = "0.2.0" # x-release-please-version diff --git a/src/context/dev/resources/__init__.py b/src/context/dev/resources/__init__.py index ffb8f92..2bcb6db 100644 --- a/src/context/dev/resources/__init__.py +++ b/src/context/dev/resources/__init__.py @@ -1,5 +1,21 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .ai import ( + AIResource, + AsyncAIResource, + AIResourceWithRawResponse, + AsyncAIResourceWithRawResponse, + AIResourceWithStreamingResponse, + AsyncAIResourceWithStreamingResponse, +) +from .web import ( + WebResource, + AsyncWebResource, + WebResourceWithRawResponse, + AsyncWebResourceWithRawResponse, + WebResourceWithStreamingResponse, + AsyncWebResourceWithStreamingResponse, +) from .brand import ( BrandResource, AsyncBrandResource, @@ -8,12 +24,66 @@ BrandResourceWithStreamingResponse, AsyncBrandResourceWithStreamingResponse, ) +from .style import ( + StyleResource, + AsyncStyleResource, + StyleResourceWithRawResponse, + AsyncStyleResourceWithRawResponse, + StyleResourceWithStreamingResponse, + AsyncStyleResourceWithStreamingResponse, +) +from .utility import ( + UtilityResource, + AsyncUtilityResource, + UtilityResourceWithRawResponse, + AsyncUtilityResourceWithRawResponse, + UtilityResourceWithStreamingResponse, + AsyncUtilityResourceWithStreamingResponse, +) +from .industry import ( + IndustryResource, + AsyncIndustryResource, + IndustryResourceWithRawResponse, + AsyncIndustryResourceWithRawResponse, + IndustryResourceWithStreamingResponse, + AsyncIndustryResourceWithStreamingResponse, +) __all__ = [ + "WebResource", + "AsyncWebResource", + "WebResourceWithRawResponse", + "AsyncWebResourceWithRawResponse", + "WebResourceWithStreamingResponse", + "AsyncWebResourceWithStreamingResponse", + "AIResource", + "AsyncAIResource", + "AIResourceWithRawResponse", + "AsyncAIResourceWithRawResponse", + "AIResourceWithStreamingResponse", + "AsyncAIResourceWithStreamingResponse", + "StyleResource", + "AsyncStyleResource", + "StyleResourceWithRawResponse", + "AsyncStyleResourceWithRawResponse", + "StyleResourceWithStreamingResponse", + "AsyncStyleResourceWithStreamingResponse", "BrandResource", "AsyncBrandResource", "BrandResourceWithRawResponse", "AsyncBrandResourceWithRawResponse", "BrandResourceWithStreamingResponse", "AsyncBrandResourceWithStreamingResponse", + "IndustryResource", + "AsyncIndustryResource", + "IndustryResourceWithRawResponse", + "AsyncIndustryResourceWithRawResponse", + "IndustryResourceWithStreamingResponse", + "AsyncIndustryResourceWithStreamingResponse", + "UtilityResource", + "AsyncUtilityResource", + "UtilityResourceWithRawResponse", + "AsyncUtilityResourceWithRawResponse", + "UtilityResourceWithStreamingResponse", + "AsyncUtilityResourceWithStreamingResponse", ] diff --git a/src/context/dev/resources/ai.py b/src/context/dev/resources/ai.py new file mode 100644 index 0000000..68bbfe0 --- /dev/null +++ b/src/context/dev/resources/ai.py @@ -0,0 +1,550 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import overload + +import httpx + +from ..types import ai_ai_query_params, ai_extract_product_params, ai_extract_products_params +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import required_args, maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.ai_ai_query_response import AIAIQueryResponse +from ..types.ai_extract_product_response import AIExtractProductResponse +from ..types.ai_extract_products_response import AIExtractProductsResponse + +__all__ = ["AIResource", "AsyncAIResource"] + + +class AIResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AIResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return AIResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AIResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return AIResourceWithStreamingResponse(self) + + def ai_query( + self, + *, + data_to_extract: Iterable[ai_ai_query_params.DataToExtract], + domain: str, + specific_pages: ai_ai_query_params.SpecificPages | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIAIQueryResponse: + """Use AI to extract specific data points from a brand's website. + + The AI will crawl + the website and extract the requested information based on the provided data + points. + + Args: + data_to_extract: Array of data points to extract from the website + + domain: The domain name to analyze + + specific_pages: Optional object specifying which pages to analyze + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/brand/ai/query", + body=maybe_transform( + { + "data_to_extract": data_to_extract, + "domain": domain, + "specific_pages": specific_pages, + "timeout_ms": timeout_ms, + }, + ai_ai_query_params.AIAIQueryParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AIAIQueryResponse, + ) + + def extract_product( + self, + *, + url: str, + 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIExtractProductResponse: + """ + Beta feature: Given a single URL, determines if it is a product detail page, + classifies the platform/product type, and extracts the product information. + Supports Amazon, TikTok Shop, Etsy, and generic ecommerce sites. + + Args: + url: The product page URL to extract product data from. + + timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is + 300000ms (5 minutes). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/brand/ai/product", + body=maybe_transform( + { + "url": url, + "timeout_ms": timeout_ms, + }, + ai_extract_product_params.AIExtractProductParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AIExtractProductResponse, + ) + + @overload + def extract_products( + self, + *, + domain: str, + max_products: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIExtractProductsResponse: + """Beta feature: Extract product information from a brand's website. + + Brand.dev will + analyze the website and return a list of products with details such as name, + description, image, pricing, features, and more. + + Args: + domain: The domain name to analyze. + + max_products: Maximum number of products to extract. + + timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is + 300000ms (5 minutes). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def extract_products( + self, + *, + direct_url: str, + max_products: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIExtractProductsResponse: + """Beta feature: Extract product information from a brand's website. + + Brand.dev will + analyze the website and return a list of products with details such as name, + description, image, pricing, features, and more. + + Args: + direct_url: A specific URL to use directly as the starting point for extraction without + domain resolution. + + max_products: Maximum number of products to extract. + + timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is + 300000ms (5 minutes). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["domain"], ["direct_url"]) + def extract_products( + self, + *, + domain: str | Omit = omit, + max_products: int | Omit = omit, + timeout_ms: int | Omit = omit, + direct_url: 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIExtractProductsResponse: + return self._post( + "/brand/ai/products", + body=maybe_transform( + { + "domain": domain, + "max_products": max_products, + "timeout_ms": timeout_ms, + "direct_url": direct_url, + }, + ai_extract_products_params.AIExtractProductsParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AIExtractProductsResponse, + ) + + +class AsyncAIResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAIResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncAIResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAIResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return AsyncAIResourceWithStreamingResponse(self) + + async def ai_query( + self, + *, + data_to_extract: Iterable[ai_ai_query_params.DataToExtract], + domain: str, + specific_pages: ai_ai_query_params.SpecificPages | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIAIQueryResponse: + """Use AI to extract specific data points from a brand's website. + + The AI will crawl + the website and extract the requested information based on the provided data + points. + + Args: + data_to_extract: Array of data points to extract from the website + + domain: The domain name to analyze + + specific_pages: Optional object specifying which pages to analyze + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/brand/ai/query", + body=await async_maybe_transform( + { + "data_to_extract": data_to_extract, + "domain": domain, + "specific_pages": specific_pages, + "timeout_ms": timeout_ms, + }, + ai_ai_query_params.AIAIQueryParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AIAIQueryResponse, + ) + + async def extract_product( + self, + *, + url: str, + 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIExtractProductResponse: + """ + Beta feature: Given a single URL, determines if it is a product detail page, + classifies the platform/product type, and extracts the product information. + Supports Amazon, TikTok Shop, Etsy, and generic ecommerce sites. + + Args: + url: The product page URL to extract product data from. + + timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is + 300000ms (5 minutes). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/brand/ai/product", + body=await async_maybe_transform( + { + "url": url, + "timeout_ms": timeout_ms, + }, + ai_extract_product_params.AIExtractProductParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AIExtractProductResponse, + ) + + @overload + async def extract_products( + self, + *, + domain: str, + max_products: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIExtractProductsResponse: + """Beta feature: Extract product information from a brand's website. + + Brand.dev will + analyze the website and return a list of products with details such as name, + description, image, pricing, features, and more. + + Args: + domain: The domain name to analyze. + + max_products: Maximum number of products to extract. + + timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is + 300000ms (5 minutes). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def extract_products( + self, + *, + direct_url: str, + max_products: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIExtractProductsResponse: + """Beta feature: Extract product information from a brand's website. + + Brand.dev will + analyze the website and return a list of products with details such as name, + description, image, pricing, features, and more. + + Args: + direct_url: A specific URL to use directly as the starting point for extraction without + domain resolution. + + max_products: Maximum number of products to extract. + + timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is + 300000ms (5 minutes). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["domain"], ["direct_url"]) + async def extract_products( + self, + *, + domain: str | Omit = omit, + max_products: int | Omit = omit, + timeout_ms: int | Omit = omit, + direct_url: 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AIExtractProductsResponse: + return await self._post( + "/brand/ai/products", + body=await async_maybe_transform( + { + "domain": domain, + "max_products": max_products, + "timeout_ms": timeout_ms, + "direct_url": direct_url, + }, + ai_extract_products_params.AIExtractProductsParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AIExtractProductsResponse, + ) + + +class AIResourceWithRawResponse: + def __init__(self, ai: AIResource) -> None: + self._ai = ai + + self.ai_query = to_raw_response_wrapper( + ai.ai_query, + ) + self.extract_product = to_raw_response_wrapper( + ai.extract_product, + ) + self.extract_products = to_raw_response_wrapper( + ai.extract_products, + ) + + +class AsyncAIResourceWithRawResponse: + def __init__(self, ai: AsyncAIResource) -> None: + self._ai = ai + + self.ai_query = async_to_raw_response_wrapper( + ai.ai_query, + ) + self.extract_product = async_to_raw_response_wrapper( + ai.extract_product, + ) + self.extract_products = async_to_raw_response_wrapper( + ai.extract_products, + ) + + +class AIResourceWithStreamingResponse: + def __init__(self, ai: AIResource) -> None: + self._ai = ai + + self.ai_query = to_streamed_response_wrapper( + ai.ai_query, + ) + self.extract_product = to_streamed_response_wrapper( + ai.extract_product, + ) + self.extract_products = to_streamed_response_wrapper( + ai.extract_products, + ) + + +class AsyncAIResourceWithStreamingResponse: + def __init__(self, ai: AsyncAIResource) -> None: + self._ai = ai + + self.ai_query = async_to_streamed_response_wrapper( + ai.ai_query, + ) + self.extract_product = async_to_streamed_response_wrapper( + ai.extract_product, + ) + self.extract_products = async_to_streamed_response_wrapper( + ai.extract_products, + ) diff --git a/src/context/dev/resources/brand.py b/src/context/dev/resources/brand.py index dbcacdc..7d52db8 100644 --- a/src/context/dev/resources/brand.py +++ b/src/context/dev/resources/brand.py @@ -2,35 +2,21 @@ from __future__ import annotations -from typing import Iterable -from typing_extensions import Literal, overload +from typing_extensions import Literal import httpx from ..types import ( - brand_fonts_params, - brand_ai_query_params, - brand_prefetch_params, brand_retrieve_params, - brand_ai_product_params, - brand_screenshot_params, - brand_styleguide_params, - brand_ai_products_params, - brand_web_scrape_md_params, - brand_retrieve_naics_params, - brand_web_scrape_html_params, brand_retrieve_by_isin_params, brand_retrieve_by_name_params, - brand_prefetch_by_email_params, brand_retrieve_by_email_params, - brand_web_scrape_images_params, brand_retrieve_by_ticker_params, - brand_web_scrape_sitemap_params, brand_retrieve_simplified_params, brand_identify_from_transaction_params, ) from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given -from .._utils import required_args, maybe_transform, async_maybe_transform +from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import ( @@ -40,24 +26,11 @@ async_to_streamed_response_wrapper, ) from .._base_client import make_request_options -from ..types.brand_fonts_response import BrandFontsResponse -from ..types.brand_ai_query_response import BrandAIQueryResponse -from ..types.brand_prefetch_response import BrandPrefetchResponse from ..types.brand_retrieve_response import BrandRetrieveResponse -from ..types.brand_ai_product_response import BrandAIProductResponse -from ..types.brand_screenshot_response import BrandScreenshotResponse -from ..types.brand_styleguide_response import BrandStyleguideResponse -from ..types.brand_ai_products_response import BrandAIProductsResponse -from ..types.brand_web_scrape_md_response import BrandWebScrapeMdResponse -from ..types.brand_retrieve_naics_response import BrandRetrieveNaicsResponse -from ..types.brand_web_scrape_html_response import BrandWebScrapeHTMLResponse from ..types.brand_retrieve_by_isin_response import BrandRetrieveByIsinResponse from ..types.brand_retrieve_by_name_response import BrandRetrieveByNameResponse -from ..types.brand_prefetch_by_email_response import BrandPrefetchByEmailResponse from ..types.brand_retrieve_by_email_response import BrandRetrieveByEmailResponse -from ..types.brand_web_scrape_images_response import BrandWebScrapeImagesResponse from ..types.brand_retrieve_by_ticker_response import BrandRetrieveByTickerResponse -from ..types.brand_web_scrape_sitemap_response import BrandWebScrapeSitemapResponse from ..types.brand_retrieve_simplified_response import BrandRetrieveSimplifiedResponse from ..types.brand_identify_from_transaction_response import BrandIdentifyFromTransactionResponse @@ -94,6 +67,7 @@ def retrieve( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -113,6 +87,7 @@ def retrieve( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -135,6 +110,7 @@ def retrieve( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -199,267 +175,6 @@ def retrieve( cast_to=BrandRetrieveResponse, ) - def ai_product( - self, - *, - url: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIProductResponse: - """ - Beta feature: Given a single URL, determines if it is a product detail page, - classifies the platform/product type, and extracts the product information. - Supports Amazon, TikTok Shop, Etsy, and generic ecommerce sites. - - Args: - url: The product page URL to extract product data from. - - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/brand/ai/product", - body=maybe_transform( - { - "url": url, - "timeout_ms": timeout_ms, - }, - brand_ai_product_params.BrandAIProductParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandAIProductResponse, - ) - - @overload - def ai_products( - self, - *, - domain: str, - max_products: 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIProductsResponse: - """Beta feature: Extract product information from a brand's website. - - Brand.dev will - analyze the website and return a list of products with details such as name, - description, image, pricing, features, and more. - - Args: - domain: The domain name to analyze. - - max_products: Maximum number of products to extract. - - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @overload - def ai_products( - self, - *, - direct_url: str, - max_products: 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIProductsResponse: - """Beta feature: Extract product information from a brand's website. - - Brand.dev will - analyze the website and return a list of products with details such as name, - description, image, pricing, features, and more. - - Args: - direct_url: A specific URL to use directly as the starting point for extraction without - domain resolution. - - max_products: Maximum number of products to extract. - - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @required_args(["domain"], ["direct_url"]) - def ai_products( - self, - *, - domain: str | Omit = omit, - max_products: int | Omit = omit, - timeout_ms: int | Omit = omit, - direct_url: 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. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIProductsResponse: - return self._post( - "/brand/ai/products", - body=maybe_transform( - { - "domain": domain, - "max_products": max_products, - "timeout_ms": timeout_ms, - "direct_url": direct_url, - }, - brand_ai_products_params.BrandAIProductsParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandAIProductsResponse, - ) - - def ai_query( - self, - *, - data_to_extract: Iterable[brand_ai_query_params.DataToExtract], - domain: str, - specific_pages: brand_ai_query_params.SpecificPages | 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIQueryResponse: - """Use AI to extract specific data points from a brand's website. - - The AI will crawl - the website and extract the requested information based on the provided data - points. - - Args: - data_to_extract: Array of data points to extract from the website - - domain: The domain name to analyze - - specific_pages: Optional object specifying which pages to analyze - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/brand/ai/query", - body=maybe_transform( - { - "data_to_extract": data_to_extract, - "domain": domain, - "specific_pages": specific_pages, - "timeout_ms": timeout_ms, - }, - brand_ai_query_params.BrandAIQueryParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandAIQueryResponse, - ) - - def fonts( - self, - *, - domain: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandFontsResponse: - """ - Extract font information from a brand's website including font families, usage - statistics, fallbacks, and element/word counts. - - Args: - domain: Domain name to extract fonts from (e.g., 'example.com', 'google.com'). The - domain will be automatically normalized and validated. - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - "/brand/fonts", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "domain": domain, - "timeout_ms": timeout_ms, - }, - brand_fonts_params.BrandFontsParams, - ), - ), - cast_to=BrandFontsResponse, - ) - def identify_from_transaction( self, *, @@ -713,6 +428,7 @@ def identify_from_transaction( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -732,6 +448,7 @@ def identify_from_transaction( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -754,6 +471,7 @@ def identify_from_transaction( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -838,106 +556,6 @@ def identify_from_transaction( cast_to=BrandIdentifyFromTransactionResponse, ) - def prefetch( - self, - *, - domain: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandPrefetchResponse: - """ - Signal that you may fetch brand data for a particular domain soon to improve - latency. This endpoint does not charge credits and is available for paid - customers to optimize future requests. [You must be on a paid plan to use this - endpoint] - - Args: - domain: Domain name to prefetch brand data for - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/brand/prefetch", - body=maybe_transform( - { - "domain": domain, - "timeout_ms": timeout_ms, - }, - brand_prefetch_params.BrandPrefetchParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandPrefetchResponse, - ) - - def prefetch_by_email( - self, - *, - email: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandPrefetchByEmailResponse: - """ - Signal that you may fetch brand data for a particular domain soon to improve - latency. This endpoint accepts an email address, extracts the domain from it, - validates that it's not a disposable or free email provider, and queues the - domain for prefetching. This endpoint does not charge credits and is available - for paid customers to optimize future requests. [You must be on a paid plan to - use this endpoint] - - Args: - email: Email address to prefetch brand data for. The domain will be extracted from the - email. Free email providers (gmail.com, yahoo.com, etc.) and disposable email - addresses are not allowed. - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/brand/prefetch-by-email", - body=maybe_transform( - { - "email": email, - "timeout_ms": timeout_ms, - }, - brand_prefetch_by_email_params.BrandPrefetchByEmailParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandPrefetchByEmailResponse, - ) - def retrieve_by_email( self, *, @@ -948,6 +566,7 @@ def retrieve_by_email( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -967,6 +586,7 @@ def retrieve_by_email( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -989,6 +609,7 @@ def retrieve_by_email( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -1065,6 +686,7 @@ def retrieve_by_isin( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -1084,6 +706,7 @@ def retrieve_by_isin( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -1106,6 +729,7 @@ def retrieve_by_isin( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -1423,6 +1047,7 @@ def retrieve_by_name( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -1442,6 +1067,7 @@ def retrieve_by_name( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -1464,6 +1090,7 @@ def retrieve_by_name( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -1542,6 +1169,7 @@ def retrieve_by_ticker( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -1561,6 +1189,7 @@ def retrieve_by_ticker( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -1583,6 +1212,7 @@ def retrieve_by_ticker( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -1725,12 +1355,10 @@ def retrieve_by_ticker( cast_to=BrandRetrieveByTickerResponse, ) - def retrieve_naics( + def retrieve_simplified( self, *, - input: str, - max_results: int | Omit = omit, - min_results: int | Omit = omit, + domain: str, 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. @@ -1738,19 +1366,14 @@ def retrieve_naics( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandRetrieveNaicsResponse: + ) -> BrandRetrieveSimplifiedResponse: """ - Endpoint to classify any brand into a 2022 NAICS code. + Returns a simplified version of brand data containing only essential + information: domain, title, colors, logos, and backdrops. This endpoint is + optimized for faster responses and reduced data transfer. Args: - input: Brand domain or title to retrieve NAICS code for. If a valid domain is provided - in `input`, it will be used for classification, otherwise, we will search for - the brand using the provided title. - - max_results: Maximum number of NAICS codes to return. Must be between 1 and 10. Defaults - to 5. - - min_results: Minimum number of NAICS codes to return. Must be at least 1. Defaults to 1. + domain: Domain name to retrieve simplified brand data for 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 @@ -1765,7 +1388,7 @@ def retrieve_naics( timeout: Override the client-level default timeout for this request, in seconds """ return self._get( - "/brand/naics", + "/brand/retrieve-simplified", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -1773,371 +1396,13 @@ def retrieve_naics( timeout=timeout, query=maybe_transform( { - "input": input, - "max_results": max_results, - "min_results": min_results, + "domain": domain, "timeout_ms": timeout_ms, }, - brand_retrieve_naics_params.BrandRetrieveNaicsParams, + brand_retrieve_simplified_params.BrandRetrieveSimplifiedParams, ), ), - cast_to=BrandRetrieveNaicsResponse, - ) - - def retrieve_simplified( - self, - *, - domain: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandRetrieveSimplifiedResponse: - """ - Returns a simplified version of brand data containing only essential - information: domain, title, colors, logos, and backdrops. This endpoint is - optimized for faster responses and reduced data transfer. - - Args: - domain: Domain name to retrieve simplified brand data for - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - "/brand/retrieve-simplified", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "domain": domain, - "timeout_ms": timeout_ms, - }, - brand_retrieve_simplified_params.BrandRetrieveSimplifiedParams, - ), - ), - cast_to=BrandRetrieveSimplifiedResponse, - ) - - def screenshot( - self, - *, - domain: str, - full_screenshot: Literal["true", "false"] | Omit = omit, - page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] | Omit = omit, - prioritize: Literal["speed", "quality"] | 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandScreenshotResponse: - """Capture a screenshot of a website. - - Supports both viewport (standard browser - view) and full-page screenshots. Can also screenshot specific page types (login, - pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to - the uploaded screenshot image hosted on our CDN. - - Args: - domain: Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The - domain will be automatically normalized and validated. - - full_screenshot: Optional parameter to determine screenshot type. If 'true', takes a full page - screenshot capturing all content. If 'false' or not provided, takes a viewport - screenshot (standard browser view). - - 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 - provided, screenshots the main domain landing page. - - prioritize: Optional parameter to prioritize screenshot capture. If 'speed', optimizes for - faster capture with basic quality. If 'quality', optimizes for higher quality - with longer wait times. Defaults to 'quality' if not provided. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - "/brand/screenshot", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "domain": domain, - "full_screenshot": full_screenshot, - "page": page, - "prioritize": prioritize, - }, - brand_screenshot_params.BrandScreenshotParams, - ), - ), - cast_to=BrandScreenshotResponse, - ) - - def styleguide( - self, - *, - direct_url: str | Omit = omit, - domain: str | Omit = omit, - prioritize: Literal["speed", "quality"] | 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandStyleguideResponse: - """ - Automatically extract comprehensive design system information from a brand's - website including colors, typography, spacing, shadows, and UI components. - Either 'domain' or 'directUrl' must be provided as a query parameter, but not - both. - - Args: - direct_url: A specific URL to fetch the styleguide from directly, bypassing domain - resolution (e.g., 'https://example.com/design-system'). - - domain: Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The - domain will be automatically normalized and validated. - - prioritize: Optional parameter to prioritize screenshot capture for styleguide extraction. - If 'speed', optimizes for 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). - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - "/brand/styleguide", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "direct_url": direct_url, - "domain": domain, - "prioritize": prioritize, - "timeout_ms": timeout_ms, - }, - brand_styleguide_params.BrandStyleguideParams, - ), - ), - cast_to=BrandStyleguideResponse, - ) - - def web_scrape_html( - self, - *, - url: str, - # 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandWebScrapeHTMLResponse: - """Scrapes the given URL and returns the raw HTML content of the page. - - Uses - automatic proxy escalation to handle blocked sites. - - Args: - url: Full URL to scrape (must include http:// or https:// protocol) - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - "/web/scrape/html", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"url": url}, brand_web_scrape_html_params.BrandWebScrapeHTMLParams), - ), - cast_to=BrandWebScrapeHTMLResponse, - ) - - def web_scrape_images( - self, - *, - url: str, - # 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandWebScrapeImagesResponse: - """Scrapes all images from the given URL. - - Extracts images from img, svg, - picture/source, link, and video elements including inline SVGs, base64 data - URIs, and standard URLs. - - Args: - url: Full URL to scrape images from (must include http:// or https:// protocol) - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - "/web/scrape/images", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"url": url}, brand_web_scrape_images_params.BrandWebScrapeImagesParams), - ), - cast_to=BrandWebScrapeImagesResponse, - ) - - def web_scrape_md( - self, - *, - url: str, - include_images: bool | Omit = omit, - include_links: bool | Omit = omit, - shorten_base64_images: 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. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandWebScrapeMdResponse: - """ - Scrapes the given URL, converts the HTML content to GitHub Flavored Markdown - (GFM), and returns the result. Uses automatic proxy escalation to handle blocked - sites. - - Args: - url: Full URL to scrape and convert to markdown (must include http:// or https:// - protocol) - - include_images: Include image references in Markdown output - - include_links: Preserve hyperlinks in Markdown output - - shorten_base64_images: Shorten base64-encoded image data in the Markdown output - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - "/web/scrape/markdown", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "url": url, - "include_images": include_images, - "include_links": include_links, - "shorten_base64_images": shorten_base64_images, - }, - brand_web_scrape_md_params.BrandWebScrapeMdParams, - ), - ), - cast_to=BrandWebScrapeMdResponse, - ) - - def web_scrape_sitemap( - self, - *, - domain: str, - # 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandWebScrapeSitemapResponse: - """ - Crawls the sitemap of the given domain and returns all discovered page URLs. - Supports sitemap index files (recursive), parallel fetching with concurrency - control, deduplication, and filters out non-page resources (images, PDFs, etc.). - - Args: - domain: Domain name to crawl sitemaps for (e.g., 'example.com'). The domain will be - automatically normalized and validated. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get( - "/web/scrape/sitemap", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"domain": domain}, brand_web_scrape_sitemap_params.BrandWebScrapeSitemapParams), - ), - cast_to=BrandWebScrapeSitemapResponse, + cast_to=BrandRetrieveSimplifiedResponse, ) @@ -2171,6 +1436,7 @@ async def retrieve( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -2190,6 +1456,7 @@ async def retrieve( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -2212,6 +1479,7 @@ async def retrieve( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -2276,268 +1544,7 @@ async def retrieve( cast_to=BrandRetrieveResponse, ) - async def ai_product( - self, - *, - url: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIProductResponse: - """ - Beta feature: Given a single URL, determines if it is a product detail page, - classifies the platform/product type, and extracts the product information. - Supports Amazon, TikTok Shop, Etsy, and generic ecommerce sites. - - Args: - url: The product page URL to extract product data from. - - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/brand/ai/product", - body=await async_maybe_transform( - { - "url": url, - "timeout_ms": timeout_ms, - }, - brand_ai_product_params.BrandAIProductParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandAIProductResponse, - ) - - @overload - async def ai_products( - self, - *, - domain: str, - max_products: 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIProductsResponse: - """Beta feature: Extract product information from a brand's website. - - Brand.dev will - analyze the website and return a list of products with details such as name, - description, image, pricing, features, and more. - - Args: - domain: The domain name to analyze. - - max_products: Maximum number of products to extract. - - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @overload - async def ai_products( - self, - *, - direct_url: str, - max_products: 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIProductsResponse: - """Beta feature: Extract product information from a brand's website. - - Brand.dev will - analyze the website and return a list of products with details such as name, - description, image, pricing, features, and more. - - Args: - direct_url: A specific URL to use directly as the starting point for extraction without - domain resolution. - - max_products: Maximum number of products to extract. - - timeout_ms: Optional timeout in milliseconds for the request. Maximum allowed value is - 300000ms (5 minutes). - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @required_args(["domain"], ["direct_url"]) - async def ai_products( - self, - *, - domain: str | Omit = omit, - max_products: int | Omit = omit, - timeout_ms: int | Omit = omit, - direct_url: 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. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIProductsResponse: - return await self._post( - "/brand/ai/products", - body=await async_maybe_transform( - { - "domain": domain, - "max_products": max_products, - "timeout_ms": timeout_ms, - "direct_url": direct_url, - }, - brand_ai_products_params.BrandAIProductsParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandAIProductsResponse, - ) - - async def ai_query( - self, - *, - data_to_extract: Iterable[brand_ai_query_params.DataToExtract], - domain: str, - specific_pages: brand_ai_query_params.SpecificPages | 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandAIQueryResponse: - """Use AI to extract specific data points from a brand's website. - - The AI will crawl - the website and extract the requested information based on the provided data - points. - - Args: - data_to_extract: Array of data points to extract from the website - - domain: The domain name to analyze - - specific_pages: Optional object specifying which pages to analyze - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/brand/ai/query", - body=await async_maybe_transform( - { - "data_to_extract": data_to_extract, - "domain": domain, - "specific_pages": specific_pages, - "timeout_ms": timeout_ms, - }, - brand_ai_query_params.BrandAIQueryParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandAIQueryResponse, - ) - - async def fonts( - self, - *, - domain: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandFontsResponse: - """ - Extract font information from a brand's website including font families, usage - statistics, fallbacks, and element/word counts. - - Args: - domain: Domain name to extract fonts from (e.g., 'example.com', 'google.com'). The - domain will be automatically normalized and validated. - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - "/brand/fonts", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "domain": domain, - "timeout_ms": timeout_ms, - }, - brand_fonts_params.BrandFontsParams, - ), - ), - cast_to=BrandFontsResponse, - ) - - async def identify_from_transaction( + async def identify_from_transaction( self, *, transaction_info: str, @@ -2790,6 +1797,7 @@ async def identify_from_transaction( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -2809,6 +1817,7 @@ async def identify_from_transaction( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -2831,6 +1840,7 @@ async def identify_from_transaction( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -2915,106 +1925,6 @@ async def identify_from_transaction( cast_to=BrandIdentifyFromTransactionResponse, ) - async def prefetch( - self, - *, - domain: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandPrefetchResponse: - """ - Signal that you may fetch brand data for a particular domain soon to improve - latency. This endpoint does not charge credits and is available for paid - customers to optimize future requests. [You must be on a paid plan to use this - endpoint] - - Args: - domain: Domain name to prefetch brand data for - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/brand/prefetch", - body=await async_maybe_transform( - { - "domain": domain, - "timeout_ms": timeout_ms, - }, - brand_prefetch_params.BrandPrefetchParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandPrefetchResponse, - ) - - async def prefetch_by_email( - self, - *, - email: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandPrefetchByEmailResponse: - """ - Signal that you may fetch brand data for a particular domain soon to improve - latency. This endpoint accepts an email address, extracts the domain from it, - validates that it's not a disposable or free email provider, and queues the - domain for prefetching. This endpoint does not charge credits and is available - for paid customers to optimize future requests. [You must be on a paid plan to - use this endpoint] - - Args: - email: Email address to prefetch brand data for. The domain will be extracted from the - email. Free email providers (gmail.com, yahoo.com, etc.) and disposable email - addresses are not allowed. - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/brand/prefetch-by-email", - body=await async_maybe_transform( - { - "email": email, - "timeout_ms": timeout_ms, - }, - brand_prefetch_by_email_params.BrandPrefetchByEmailParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=BrandPrefetchByEmailResponse, - ) - async def retrieve_by_email( self, *, @@ -3025,6 +1935,7 @@ async def retrieve_by_email( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -3044,6 +1955,7 @@ async def retrieve_by_email( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -3066,6 +1978,7 @@ async def retrieve_by_email( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -3142,6 +2055,7 @@ async def retrieve_by_isin( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -3161,6 +2075,7 @@ async def retrieve_by_isin( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -3183,6 +2098,7 @@ async def retrieve_by_isin( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -3500,6 +2416,7 @@ async def retrieve_by_name( "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -3519,6 +2436,7 @@ async def retrieve_by_name( "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -3541,6 +2459,7 @@ async def retrieve_by_name( "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", @@ -3560,545 +2479,25 @@ async def retrieve_by_name( ) -> BrandRetrieveByNameResponse: """Retrieve brand information using a company name. - This endpoint searches for the - company by name and returns its brand data. - - Args: - name: Company name to retrieve brand data for (e.g., 'Apple Inc', 'Microsoft - Corporation'). Must be 3-30 characters. - - country_gl: Optional country code (GL parameter) to specify the country. This affects the - geographic location used for search queries. - - force_language: Optional parameter to force the language of the retrieved brand data. - - max_speed: Optional parameter to optimize the API call for maximum speed. When set to true, - the API will skip time-consuming operations for faster response at the cost of - less comprehensive data. - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - "/brand/retrieve-by-name", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "name": name, - "country_gl": country_gl, - "force_language": force_language, - "max_speed": max_speed, - "timeout_ms": timeout_ms, - }, - brand_retrieve_by_name_params.BrandRetrieveByNameParams, - ), - ), - cast_to=BrandRetrieveByNameResponse, - ) - - async def retrieve_by_ticker( - self, - *, - ticker: str, - force_language: Literal[ - "albanian", - "arabic", - "azeri", - "bengali", - "bulgarian", - "cebuano", - "croatian", - "czech", - "danish", - "dutch", - "english", - "estonian", - "farsi", - "finnish", - "french", - "german", - "hausa", - "hawaiian", - "hindi", - "hungarian", - "icelandic", - "indonesian", - "italian", - "kazakh", - "kyrgyz", - "latin", - "latvian", - "lithuanian", - "macedonian", - "mongolian", - "nepali", - "norwegian", - "pashto", - "pidgin", - "polish", - "portuguese", - "romanian", - "russian", - "serbian", - "slovak", - "slovene", - "somali", - "spanish", - "swahili", - "swedish", - "tagalog", - "turkish", - "ukrainian", - "urdu", - "uzbek", - "vietnamese", - "welsh", - ] - | Omit = omit, - max_speed: bool | Omit = omit, - ticker_exchange: Literal[ - "AMEX", - "AMS", - "AQS", - "ASX", - "ATH", - "BER", - "BME", - "BRU", - "BSE", - "BUD", - "BUE", - "BVC", - "CBOE", - "CNQ", - "CPH", - "DFM", - "DOH", - "DUB", - "DUS", - "DXE", - "EGX", - "FSX", - "HAM", - "HEL", - "HKSE", - "HOSE", - "ICE", - "IOB", - "IST", - "JKT", - "JNB", - "JPX", - "KLS", - "KOE", - "KSC", - "KUW", - "LIS", - "LSE", - "MCX", - "MEX", - "MIL", - "MUN", - "NASDAQ", - "NEO", - "NSE", - "NYSE", - "NZE", - "OSL", - "OTC", - "PAR", - "PNK", - "PRA", - "RIS", - "SAO", - "SAU", - "SES", - "SET", - "SGO", - "SHH", - "SHZ", - "SIX", - "STO", - "STU", - "TAI", - "TAL", - "TLV", - "TSX", - "TSXV", - "TWO", - "VIE", - "WSE", - "XETRA", - ] - | 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandRetrieveByTickerResponse: - """Retrieve brand information using a stock ticker symbol. - - This endpoint looks up - the company associated with the ticker and returns its brand data. - - Args: - ticker: Stock ticker symbol to retrieve brand data for (e.g., 'AAPL', 'GOOGL', 'BRK.A'). - Must be 1-15 characters, letters/numbers/dots only. - - force_language: Optional parameter to force the language of the retrieved brand data. - - max_speed: Optional parameter to optimize the API call for maximum speed. When set to true, - the API will skip time-consuming operations for faster response at the cost of - less comprehensive data. - - ticker_exchange: Optional stock exchange for the ticker. Defaults to NASDAQ if not specified. - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - "/brand/retrieve-by-ticker", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "ticker": ticker, - "force_language": force_language, - "max_speed": max_speed, - "ticker_exchange": ticker_exchange, - "timeout_ms": timeout_ms, - }, - brand_retrieve_by_ticker_params.BrandRetrieveByTickerParams, - ), - ), - cast_to=BrandRetrieveByTickerResponse, - ) - - async def retrieve_naics( - self, - *, - input: str, - max_results: int | Omit = omit, - min_results: 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandRetrieveNaicsResponse: - """ - Endpoint to classify any brand into a 2022 NAICS code. - - Args: - input: Brand domain or title to retrieve NAICS code for. If a valid domain is provided - in `input`, it will be used for classification, otherwise, we will search for - the brand using the provided title. - - max_results: Maximum number of NAICS codes to return. Must be between 1 and 10. Defaults - to 5. - - min_results: Minimum number of NAICS codes to return. Must be at least 1. Defaults to 1. - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - "/brand/naics", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "input": input, - "max_results": max_results, - "min_results": min_results, - "timeout_ms": timeout_ms, - }, - brand_retrieve_naics_params.BrandRetrieveNaicsParams, - ), - ), - cast_to=BrandRetrieveNaicsResponse, - ) - - async def retrieve_simplified( - self, - *, - domain: str, - 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandRetrieveSimplifiedResponse: - """ - Returns a simplified version of brand data containing only essential - information: domain, title, colors, logos, and backdrops. This endpoint is - optimized for faster responses and reduced data transfer. - - Args: - domain: Domain name to retrieve simplified brand data for - - 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 - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - "/brand/retrieve-simplified", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "domain": domain, - "timeout_ms": timeout_ms, - }, - brand_retrieve_simplified_params.BrandRetrieveSimplifiedParams, - ), - ), - cast_to=BrandRetrieveSimplifiedResponse, - ) - - async def screenshot( - self, - *, - domain: str, - full_screenshot: Literal["true", "false"] | Omit = omit, - page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] | Omit = omit, - prioritize: Literal["speed", "quality"] | 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandScreenshotResponse: - """Capture a screenshot of a website. - - Supports both viewport (standard browser - view) and full-page screenshots. Can also screenshot specific page types (login, - pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to - the uploaded screenshot image hosted on our CDN. - - Args: - domain: Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The - domain will be automatically normalized and validated. - - full_screenshot: Optional parameter to determine screenshot type. If 'true', takes a full page - screenshot capturing all content. If 'false' or not provided, takes a viewport - screenshot (standard browser view). - - 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 - provided, screenshots the main domain landing page. - - prioritize: Optional parameter to prioritize screenshot capture. If 'speed', optimizes for - faster capture with basic quality. If 'quality', optimizes for higher quality - with longer wait times. Defaults to 'quality' if not provided. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - "/brand/screenshot", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "domain": domain, - "full_screenshot": full_screenshot, - "page": page, - "prioritize": prioritize, - }, - brand_screenshot_params.BrandScreenshotParams, - ), - ), - cast_to=BrandScreenshotResponse, - ) - - async def styleguide( - self, - *, - direct_url: str | Omit = omit, - domain: str | Omit = omit, - prioritize: Literal["speed", "quality"] | 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandStyleguideResponse: - """ - Automatically extract comprehensive design system information from a brand's - website including colors, typography, spacing, shadows, and UI components. - Either 'domain' or 'directUrl' must be provided as a query parameter, but not - both. - - Args: - direct_url: A specific URL to fetch the styleguide from directly, bypassing domain - resolution (e.g., 'https://example.com/design-system'). - - domain: Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The - domain will be automatically normalized and validated. - - prioritize: Optional parameter to prioritize screenshot capture for styleguide extraction. - If 'speed', optimizes for 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). - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - "/brand/styleguide", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "direct_url": direct_url, - "domain": domain, - "prioritize": prioritize, - "timeout_ms": timeout_ms, - }, - brand_styleguide_params.BrandStyleguideParams, - ), - ), - cast_to=BrandStyleguideResponse, - ) - - async def web_scrape_html( - self, - *, - url: str, - # 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandWebScrapeHTMLResponse: - """Scrapes the given URL and returns the raw HTML content of the page. - - Uses - automatic proxy escalation to handle blocked sites. - - Args: - url: Full URL to scrape (must include http:// or https:// protocol) - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._get( - "/web/scrape/html", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"url": url}, brand_web_scrape_html_params.BrandWebScrapeHTMLParams), - ), - cast_to=BrandWebScrapeHTMLResponse, - ) - - async def web_scrape_images( - self, - *, - url: str, - # 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, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandWebScrapeImagesResponse: - """Scrapes all images from the given URL. - - Extracts images from img, svg, - picture/source, link, and video elements including inline SVGs, base64 data - URIs, and standard URLs. + This endpoint searches for the + company by name and returns its brand data. Args: - url: Full URL to scrape images from (must include http:// or https:// protocol) + name: Company name to retrieve brand data for (e.g., 'Apple Inc', 'Microsoft + Corporation'). Must be 3-30 characters. + + country_gl: Optional country code (GL parameter) to specify the country. This affects the + geographic location used for search queries. + + force_language: Optional parameter to force the language of the retrieved brand data. + + max_speed: Optional parameter to optimize the API call for maximum speed. When set to true, + the API will skip time-consuming operations for faster response at the cost of + less comprehensive data. + + 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 @@ -4109,47 +2508,192 @@ async def web_scrape_images( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/web/scrape/images", + "/brand/retrieve-by-name", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=await async_maybe_transform( - {"url": url}, brand_web_scrape_images_params.BrandWebScrapeImagesParams + { + "name": name, + "country_gl": country_gl, + "force_language": force_language, + "max_speed": max_speed, + "timeout_ms": timeout_ms, + }, + brand_retrieve_by_name_params.BrandRetrieveByNameParams, ), ), - cast_to=BrandWebScrapeImagesResponse, + cast_to=BrandRetrieveByNameResponse, ) - async def web_scrape_md( + async def retrieve_by_ticker( self, *, - url: str, - include_images: bool | Omit = omit, - include_links: bool | Omit = omit, - shorten_base64_images: bool | Omit = omit, + ticker: str, + force_language: Literal[ + "albanian", + "arabic", + "azeri", + "bengali", + "bulgarian", + "cantonese", + "cebuano", + "croatian", + "czech", + "danish", + "dutch", + "english", + "estonian", + "farsi", + "finnish", + "french", + "german", + "hausa", + "hawaiian", + "hindi", + "hungarian", + "icelandic", + "indonesian", + "italian", + "kazakh", + "korean", + "kyrgyz", + "latin", + "latvian", + "lithuanian", + "macedonian", + "mongolian", + "nepali", + "norwegian", + "pashto", + "pidgin", + "polish", + "portuguese", + "romanian", + "russian", + "serbian", + "slovak", + "slovene", + "somali", + "spanish", + "swahili", + "swedish", + "tagalog", + "thai", + "turkish", + "ukrainian", + "urdu", + "uzbek", + "vietnamese", + "welsh", + ] + | Omit = omit, + max_speed: bool | Omit = omit, + ticker_exchange: Literal[ + "AMEX", + "AMS", + "AQS", + "ASX", + "ATH", + "BER", + "BME", + "BRU", + "BSE", + "BUD", + "BUE", + "BVC", + "CBOE", + "CNQ", + "CPH", + "DFM", + "DOH", + "DUB", + "DUS", + "DXE", + "EGX", + "FSX", + "HAM", + "HEL", + "HKSE", + "HOSE", + "ICE", + "IOB", + "IST", + "JKT", + "JNB", + "JPX", + "KLS", + "KOE", + "KSC", + "KUW", + "LIS", + "LSE", + "MCX", + "MEX", + "MIL", + "MUN", + "NASDAQ", + "NEO", + "NSE", + "NYSE", + "NZE", + "OSL", + "OTC", + "PAR", + "PNK", + "PRA", + "RIS", + "SAO", + "SAU", + "SES", + "SET", + "SGO", + "SHH", + "SHZ", + "SIX", + "STO", + "STU", + "TAI", + "TAL", + "TLV", + "TSX", + "TSXV", + "TWO", + "VIE", + "WSE", + "XETRA", + ] + | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandWebScrapeMdResponse: - """ - Scrapes the given URL, converts the HTML content to GitHub Flavored Markdown - (GFM), and returns the result. Uses automatic proxy escalation to handle blocked - sites. + ) -> BrandRetrieveByTickerResponse: + """Retrieve brand information using a stock ticker symbol. + + This endpoint looks up + the company associated with the ticker and returns its brand data. Args: - url: Full URL to scrape and convert to markdown (must include http:// or https:// - protocol) + ticker: Stock ticker symbol to retrieve brand data for (e.g., 'AAPL', 'GOOGL', 'BRK.A'). + Must be 1-15 characters, letters/numbers/dots only. + + force_language: Optional parameter to force the language of the retrieved brand data. - include_images: Include image references in Markdown output + max_speed: Optional parameter to optimize the API call for maximum speed. When set to true, + the API will skip time-consuming operations for faster response at the cost of + less comprehensive data. - include_links: Preserve hyperlinks in Markdown output + ticker_exchange: Optional stock exchange for the ticker. Defaults to NASDAQ if not specified. - 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). extra_headers: Send extra headers @@ -4160,7 +2704,7 @@ async def web_scrape_md( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/web/scrape/markdown", + "/brand/retrieve-by-ticker", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -4168,36 +2712,41 @@ async def web_scrape_md( timeout=timeout, query=await async_maybe_transform( { - "url": url, - "include_images": include_images, - "include_links": include_links, - "shorten_base64_images": shorten_base64_images, + "ticker": ticker, + "force_language": force_language, + "max_speed": max_speed, + "ticker_exchange": ticker_exchange, + "timeout_ms": timeout_ms, }, - brand_web_scrape_md_params.BrandWebScrapeMdParams, + brand_retrieve_by_ticker_params.BrandRetrieveByTickerParams, ), ), - cast_to=BrandWebScrapeMdResponse, + cast_to=BrandRetrieveByTickerResponse, ) - async def web_scrape_sitemap( + async def retrieve_simplified( self, *, domain: str, + 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> BrandWebScrapeSitemapResponse: + ) -> BrandRetrieveSimplifiedResponse: """ - Crawls the sitemap of the given domain and returns all discovered page URLs. - Supports sitemap index files (recursive), parallel fetching with concurrency - control, deduplication, and filters out non-page resources (images, PDFs, etc.). + Returns a simplified version of brand data containing only essential + information: domain, title, colors, logos, and backdrops. This endpoint is + optimized for faster responses and reduced data transfer. Args: - domain: Domain name to crawl sitemaps for (e.g., 'example.com'). The domain will be - automatically normalized and validated. + domain: Domain name to retrieve simplified brand data for + + 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 @@ -4208,17 +2757,21 @@ async def web_scrape_sitemap( timeout: Override the client-level default timeout for this request, in seconds """ return await self._get( - "/web/scrape/sitemap", + "/brand/retrieve-simplified", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=await async_maybe_transform( - {"domain": domain}, brand_web_scrape_sitemap_params.BrandWebScrapeSitemapParams + { + "domain": domain, + "timeout_ms": timeout_ms, + }, + brand_retrieve_simplified_params.BrandRetrieveSimplifiedParams, ), ), - cast_to=BrandWebScrapeSitemapResponse, + cast_to=BrandRetrieveSimplifiedResponse, ) @@ -4229,27 +2782,9 @@ def __init__(self, brand: BrandResource) -> None: self.retrieve = to_raw_response_wrapper( brand.retrieve, ) - self.ai_product = to_raw_response_wrapper( - brand.ai_product, - ) - self.ai_products = to_raw_response_wrapper( - brand.ai_products, - ) - self.ai_query = to_raw_response_wrapper( - brand.ai_query, - ) - self.fonts = to_raw_response_wrapper( - brand.fonts, - ) self.identify_from_transaction = to_raw_response_wrapper( brand.identify_from_transaction, ) - self.prefetch = to_raw_response_wrapper( - brand.prefetch, - ) - self.prefetch_by_email = to_raw_response_wrapper( - brand.prefetch_by_email, - ) self.retrieve_by_email = to_raw_response_wrapper( brand.retrieve_by_email, ) @@ -4262,30 +2797,9 @@ def __init__(self, brand: BrandResource) -> None: self.retrieve_by_ticker = to_raw_response_wrapper( brand.retrieve_by_ticker, ) - self.retrieve_naics = to_raw_response_wrapper( - brand.retrieve_naics, - ) self.retrieve_simplified = to_raw_response_wrapper( brand.retrieve_simplified, ) - self.screenshot = to_raw_response_wrapper( - brand.screenshot, - ) - self.styleguide = to_raw_response_wrapper( - brand.styleguide, - ) - self.web_scrape_html = to_raw_response_wrapper( - brand.web_scrape_html, - ) - self.web_scrape_images = to_raw_response_wrapper( - brand.web_scrape_images, - ) - self.web_scrape_md = to_raw_response_wrapper( - brand.web_scrape_md, - ) - self.web_scrape_sitemap = to_raw_response_wrapper( - brand.web_scrape_sitemap, - ) class AsyncBrandResourceWithRawResponse: @@ -4295,27 +2809,9 @@ def __init__(self, brand: AsyncBrandResource) -> None: self.retrieve = async_to_raw_response_wrapper( brand.retrieve, ) - self.ai_product = async_to_raw_response_wrapper( - brand.ai_product, - ) - self.ai_products = async_to_raw_response_wrapper( - brand.ai_products, - ) - self.ai_query = async_to_raw_response_wrapper( - brand.ai_query, - ) - self.fonts = async_to_raw_response_wrapper( - brand.fonts, - ) self.identify_from_transaction = async_to_raw_response_wrapper( brand.identify_from_transaction, ) - self.prefetch = async_to_raw_response_wrapper( - brand.prefetch, - ) - self.prefetch_by_email = async_to_raw_response_wrapper( - brand.prefetch_by_email, - ) self.retrieve_by_email = async_to_raw_response_wrapper( brand.retrieve_by_email, ) @@ -4328,30 +2824,9 @@ def __init__(self, brand: AsyncBrandResource) -> None: self.retrieve_by_ticker = async_to_raw_response_wrapper( brand.retrieve_by_ticker, ) - self.retrieve_naics = async_to_raw_response_wrapper( - brand.retrieve_naics, - ) self.retrieve_simplified = async_to_raw_response_wrapper( brand.retrieve_simplified, ) - self.screenshot = async_to_raw_response_wrapper( - brand.screenshot, - ) - self.styleguide = async_to_raw_response_wrapper( - brand.styleguide, - ) - self.web_scrape_html = async_to_raw_response_wrapper( - brand.web_scrape_html, - ) - self.web_scrape_images = async_to_raw_response_wrapper( - brand.web_scrape_images, - ) - self.web_scrape_md = async_to_raw_response_wrapper( - brand.web_scrape_md, - ) - self.web_scrape_sitemap = async_to_raw_response_wrapper( - brand.web_scrape_sitemap, - ) class BrandResourceWithStreamingResponse: @@ -4361,27 +2836,9 @@ def __init__(self, brand: BrandResource) -> None: self.retrieve = to_streamed_response_wrapper( brand.retrieve, ) - self.ai_product = to_streamed_response_wrapper( - brand.ai_product, - ) - self.ai_products = to_streamed_response_wrapper( - brand.ai_products, - ) - self.ai_query = to_streamed_response_wrapper( - brand.ai_query, - ) - self.fonts = to_streamed_response_wrapper( - brand.fonts, - ) self.identify_from_transaction = to_streamed_response_wrapper( brand.identify_from_transaction, ) - self.prefetch = to_streamed_response_wrapper( - brand.prefetch, - ) - self.prefetch_by_email = to_streamed_response_wrapper( - brand.prefetch_by_email, - ) self.retrieve_by_email = to_streamed_response_wrapper( brand.retrieve_by_email, ) @@ -4394,30 +2851,9 @@ def __init__(self, brand: BrandResource) -> None: self.retrieve_by_ticker = to_streamed_response_wrapper( brand.retrieve_by_ticker, ) - self.retrieve_naics = to_streamed_response_wrapper( - brand.retrieve_naics, - ) self.retrieve_simplified = to_streamed_response_wrapper( brand.retrieve_simplified, ) - self.screenshot = to_streamed_response_wrapper( - brand.screenshot, - ) - self.styleguide = to_streamed_response_wrapper( - brand.styleguide, - ) - self.web_scrape_html = to_streamed_response_wrapper( - brand.web_scrape_html, - ) - self.web_scrape_images = to_streamed_response_wrapper( - brand.web_scrape_images, - ) - self.web_scrape_md = to_streamed_response_wrapper( - brand.web_scrape_md, - ) - self.web_scrape_sitemap = to_streamed_response_wrapper( - brand.web_scrape_sitemap, - ) class AsyncBrandResourceWithStreamingResponse: @@ -4427,27 +2863,9 @@ def __init__(self, brand: AsyncBrandResource) -> None: self.retrieve = async_to_streamed_response_wrapper( brand.retrieve, ) - self.ai_product = async_to_streamed_response_wrapper( - brand.ai_product, - ) - self.ai_products = async_to_streamed_response_wrapper( - brand.ai_products, - ) - self.ai_query = async_to_streamed_response_wrapper( - brand.ai_query, - ) - self.fonts = async_to_streamed_response_wrapper( - brand.fonts, - ) self.identify_from_transaction = async_to_streamed_response_wrapper( brand.identify_from_transaction, ) - self.prefetch = async_to_streamed_response_wrapper( - brand.prefetch, - ) - self.prefetch_by_email = async_to_streamed_response_wrapper( - brand.prefetch_by_email, - ) self.retrieve_by_email = async_to_streamed_response_wrapper( brand.retrieve_by_email, ) @@ -4460,27 +2878,6 @@ def __init__(self, brand: AsyncBrandResource) -> None: self.retrieve_by_ticker = async_to_streamed_response_wrapper( brand.retrieve_by_ticker, ) - self.retrieve_naics = async_to_streamed_response_wrapper( - brand.retrieve_naics, - ) self.retrieve_simplified = async_to_streamed_response_wrapper( brand.retrieve_simplified, ) - self.screenshot = async_to_streamed_response_wrapper( - brand.screenshot, - ) - self.styleguide = async_to_streamed_response_wrapper( - brand.styleguide, - ) - self.web_scrape_html = async_to_streamed_response_wrapper( - brand.web_scrape_html, - ) - self.web_scrape_images = async_to_streamed_response_wrapper( - brand.web_scrape_images, - ) - self.web_scrape_md = async_to_streamed_response_wrapper( - brand.web_scrape_md, - ) - self.web_scrape_sitemap = async_to_streamed_response_wrapper( - brand.web_scrape_sitemap, - ) diff --git a/src/context/dev/resources/industry.py b/src/context/dev/resources/industry.py new file mode 100644 index 0000000..8a995e5 --- /dev/null +++ b/src/context/dev/resources/industry.py @@ -0,0 +1,217 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..types import industry_retrieve_naics_params +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.industry_retrieve_naics_response import IndustryRetrieveNaicsResponse + +__all__ = ["IndustryResource", "AsyncIndustryResource"] + + +class IndustryResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> IndustryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return IndustryResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IndustryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return IndustryResourceWithStreamingResponse(self) + + def retrieve_naics( + self, + *, + input: str, + max_results: int | Omit = omit, + min_results: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IndustryRetrieveNaicsResponse: + """ + Endpoint to classify any brand into a 2022 NAICS code. + + Args: + input: Brand domain or title to retrieve NAICS code for. If a valid domain is provided + in `input`, it will be used for classification, otherwise, we will search for + the brand using the provided title. + + max_results: Maximum number of NAICS codes to return. Must be between 1 and 10. Defaults + to 5. + + min_results: Minimum number of NAICS codes to return. Must be at least 1. Defaults to 1. + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/brand/naics", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "input": input, + "max_results": max_results, + "min_results": min_results, + "timeout_ms": timeout_ms, + }, + industry_retrieve_naics_params.IndustryRetrieveNaicsParams, + ), + ), + cast_to=IndustryRetrieveNaicsResponse, + ) + + +class AsyncIndustryResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIndustryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncIndustryResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIndustryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return AsyncIndustryResourceWithStreamingResponse(self) + + async def retrieve_naics( + self, + *, + input: str, + max_results: int | Omit = omit, + min_results: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IndustryRetrieveNaicsResponse: + """ + Endpoint to classify any brand into a 2022 NAICS code. + + Args: + input: Brand domain or title to retrieve NAICS code for. If a valid domain is provided + in `input`, it will be used for classification, otherwise, we will search for + the brand using the provided title. + + max_results: Maximum number of NAICS codes to return. Must be between 1 and 10. Defaults + to 5. + + min_results: Minimum number of NAICS codes to return. Must be at least 1. Defaults to 1. + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/brand/naics", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "input": input, + "max_results": max_results, + "min_results": min_results, + "timeout_ms": timeout_ms, + }, + industry_retrieve_naics_params.IndustryRetrieveNaicsParams, + ), + ), + cast_to=IndustryRetrieveNaicsResponse, + ) + + +class IndustryResourceWithRawResponse: + def __init__(self, industry: IndustryResource) -> None: + self._industry = industry + + self.retrieve_naics = to_raw_response_wrapper( + industry.retrieve_naics, + ) + + +class AsyncIndustryResourceWithRawResponse: + def __init__(self, industry: AsyncIndustryResource) -> None: + self._industry = industry + + self.retrieve_naics = async_to_raw_response_wrapper( + industry.retrieve_naics, + ) + + +class IndustryResourceWithStreamingResponse: + def __init__(self, industry: IndustryResource) -> None: + self._industry = industry + + self.retrieve_naics = to_streamed_response_wrapper( + industry.retrieve_naics, + ) + + +class AsyncIndustryResourceWithStreamingResponse: + def __init__(self, industry: AsyncIndustryResource) -> None: + self._industry = industry + + self.retrieve_naics = async_to_streamed_response_wrapper( + industry.retrieve_naics, + ) diff --git a/src/context/dev/resources/style.py b/src/context/dev/resources/style.py new file mode 100644 index 0000000..6a7c23d --- /dev/null +++ b/src/context/dev/resources/style.py @@ -0,0 +1,342 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ..types import style_extract_fonts_params, style_extract_styleguide_params +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.style_extract_fonts_response import StyleExtractFontsResponse +from ..types.style_extract_styleguide_response import StyleExtractStyleguideResponse + +__all__ = ["StyleResource", "AsyncStyleResource"] + + +class StyleResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> StyleResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return StyleResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> StyleResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return StyleResourceWithStreamingResponse(self) + + def extract_fonts( + self, + *, + domain: str, + 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> StyleExtractFontsResponse: + """ + Extract font information from a brand's website including font families, usage + statistics, fallbacks, and element/word counts. + + Args: + domain: Domain name to extract fonts from (e.g., 'example.com', 'google.com'). The + domain will be automatically normalized and validated. + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/brand/fonts", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "domain": domain, + "timeout_ms": timeout_ms, + }, + style_extract_fonts_params.StyleExtractFontsParams, + ), + ), + cast_to=StyleExtractFontsResponse, + ) + + def extract_styleguide( + self, + *, + direct_url: str | Omit = omit, + domain: str | Omit = omit, + prioritize: Literal["speed", "quality"] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> StyleExtractStyleguideResponse: + """ + Automatically extract comprehensive design system information from a brand's + website including colors, typography, spacing, shadows, and UI components. + Either 'domain' or 'directUrl' must be provided as a query parameter, but not + both. + + Args: + direct_url: A specific URL to fetch the styleguide from directly, bypassing domain + resolution (e.g., 'https://example.com/design-system'). + + domain: Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The + domain will be automatically normalized and validated. + + prioritize: Optional parameter to prioritize screenshot capture for styleguide extraction. + If 'speed', optimizes for 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). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/brand/styleguide", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direct_url": direct_url, + "domain": domain, + "prioritize": prioritize, + "timeout_ms": timeout_ms, + }, + style_extract_styleguide_params.StyleExtractStyleguideParams, + ), + ), + cast_to=StyleExtractStyleguideResponse, + ) + + +class AsyncStyleResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncStyleResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncStyleResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncStyleResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return AsyncStyleResourceWithStreamingResponse(self) + + async def extract_fonts( + self, + *, + domain: str, + 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> StyleExtractFontsResponse: + """ + Extract font information from a brand's website including font families, usage + statistics, fallbacks, and element/word counts. + + Args: + domain: Domain name to extract fonts from (e.g., 'example.com', 'google.com'). The + domain will be automatically normalized and validated. + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/brand/fonts", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "domain": domain, + "timeout_ms": timeout_ms, + }, + style_extract_fonts_params.StyleExtractFontsParams, + ), + ), + cast_to=StyleExtractFontsResponse, + ) + + async def extract_styleguide( + self, + *, + direct_url: str | Omit = omit, + domain: str | Omit = omit, + prioritize: Literal["speed", "quality"] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> StyleExtractStyleguideResponse: + """ + Automatically extract comprehensive design system information from a brand's + website including colors, typography, spacing, shadows, and UI components. + Either 'domain' or 'directUrl' must be provided as a query parameter, but not + both. + + Args: + direct_url: A specific URL to fetch the styleguide from directly, bypassing domain + resolution (e.g., 'https://example.com/design-system'). + + domain: Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The + domain will be automatically normalized and validated. + + prioritize: Optional parameter to prioritize screenshot capture for styleguide extraction. + If 'speed', optimizes for 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). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/brand/styleguide", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "direct_url": direct_url, + "domain": domain, + "prioritize": prioritize, + "timeout_ms": timeout_ms, + }, + style_extract_styleguide_params.StyleExtractStyleguideParams, + ), + ), + cast_to=StyleExtractStyleguideResponse, + ) + + +class StyleResourceWithRawResponse: + def __init__(self, style: StyleResource) -> None: + self._style = style + + self.extract_fonts = to_raw_response_wrapper( + style.extract_fonts, + ) + self.extract_styleguide = to_raw_response_wrapper( + style.extract_styleguide, + ) + + +class AsyncStyleResourceWithRawResponse: + def __init__(self, style: AsyncStyleResource) -> None: + self._style = style + + self.extract_fonts = async_to_raw_response_wrapper( + style.extract_fonts, + ) + self.extract_styleguide = async_to_raw_response_wrapper( + style.extract_styleguide, + ) + + +class StyleResourceWithStreamingResponse: + def __init__(self, style: StyleResource) -> None: + self._style = style + + self.extract_fonts = to_streamed_response_wrapper( + style.extract_fonts, + ) + self.extract_styleguide = to_streamed_response_wrapper( + style.extract_styleguide, + ) + + +class AsyncStyleResourceWithStreamingResponse: + def __init__(self, style: AsyncStyleResource) -> None: + self._style = style + + self.extract_fonts = async_to_streamed_response_wrapper( + style.extract_fonts, + ) + self.extract_styleguide = async_to_streamed_response_wrapper( + style.extract_styleguide, + ) diff --git a/src/context/dev/resources/utility.py b/src/context/dev/resources/utility.py new file mode 100644 index 0000000..2998696 --- /dev/null +++ b/src/context/dev/resources/utility.py @@ -0,0 +1,312 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..types import utility_prefetch_params, utility_prefetch_by_email_params +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.utility_prefetch_response import UtilityPrefetchResponse +from ..types.utility_prefetch_by_email_response import UtilityPrefetchByEmailResponse + +__all__ = ["UtilityResource", "AsyncUtilityResource"] + + +class UtilityResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> UtilityResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return UtilityResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> UtilityResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return UtilityResourceWithStreamingResponse(self) + + def prefetch( + self, + *, + domain: str, + 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UtilityPrefetchResponse: + """ + Signal that you may fetch brand data for a particular domain soon to improve + latency. This endpoint does not charge credits and is available for paid + customers to optimize future requests. [You must be on a paid plan to use this + endpoint] + + Args: + domain: Domain name to prefetch brand data for + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/brand/prefetch", + body=maybe_transform( + { + "domain": domain, + "timeout_ms": timeout_ms, + }, + utility_prefetch_params.UtilityPrefetchParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=UtilityPrefetchResponse, + ) + + def prefetch_by_email( + self, + *, + email: str, + 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UtilityPrefetchByEmailResponse: + """ + Signal that you may fetch brand data for a particular domain soon to improve + latency. This endpoint accepts an email address, extracts the domain from it, + validates that it's not a disposable or free email provider, and queues the + domain for prefetching. This endpoint does not charge credits and is available + for paid customers to optimize future requests. [You must be on a paid plan to + use this endpoint] + + Args: + email: Email address to prefetch brand data for. The domain will be extracted from the + email. Free email providers (gmail.com, yahoo.com, etc.) and disposable email + addresses are not allowed. + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/brand/prefetch-by-email", + body=maybe_transform( + { + "email": email, + "timeout_ms": timeout_ms, + }, + utility_prefetch_by_email_params.UtilityPrefetchByEmailParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=UtilityPrefetchByEmailResponse, + ) + + +class AsyncUtilityResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncUtilityResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncUtilityResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncUtilityResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return AsyncUtilityResourceWithStreamingResponse(self) + + async def prefetch( + self, + *, + domain: str, + 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UtilityPrefetchResponse: + """ + Signal that you may fetch brand data for a particular domain soon to improve + latency. This endpoint does not charge credits and is available for paid + customers to optimize future requests. [You must be on a paid plan to use this + endpoint] + + Args: + domain: Domain name to prefetch brand data for + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/brand/prefetch", + body=await async_maybe_transform( + { + "domain": domain, + "timeout_ms": timeout_ms, + }, + utility_prefetch_params.UtilityPrefetchParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=UtilityPrefetchResponse, + ) + + async def prefetch_by_email( + self, + *, + email: str, + 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> UtilityPrefetchByEmailResponse: + """ + Signal that you may fetch brand data for a particular domain soon to improve + latency. This endpoint accepts an email address, extracts the domain from it, + validates that it's not a disposable or free email provider, and queues the + domain for prefetching. This endpoint does not charge credits and is available + for paid customers to optimize future requests. [You must be on a paid plan to + use this endpoint] + + Args: + email: Email address to prefetch brand data for. The domain will be extracted from the + email. Free email providers (gmail.com, yahoo.com, etc.) and disposable email + addresses are not allowed. + + 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 + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/brand/prefetch-by-email", + body=await async_maybe_transform( + { + "email": email, + "timeout_ms": timeout_ms, + }, + utility_prefetch_by_email_params.UtilityPrefetchByEmailParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=UtilityPrefetchByEmailResponse, + ) + + +class UtilityResourceWithRawResponse: + def __init__(self, utility: UtilityResource) -> None: + self._utility = utility + + self.prefetch = to_raw_response_wrapper( + utility.prefetch, + ) + self.prefetch_by_email = to_raw_response_wrapper( + utility.prefetch_by_email, + ) + + +class AsyncUtilityResourceWithRawResponse: + def __init__(self, utility: AsyncUtilityResource) -> None: + self._utility = utility + + self.prefetch = async_to_raw_response_wrapper( + utility.prefetch, + ) + self.prefetch_by_email = async_to_raw_response_wrapper( + utility.prefetch_by_email, + ) + + +class UtilityResourceWithStreamingResponse: + def __init__(self, utility: UtilityResource) -> None: + self._utility = utility + + self.prefetch = to_streamed_response_wrapper( + utility.prefetch, + ) + self.prefetch_by_email = to_streamed_response_wrapper( + utility.prefetch_by_email, + ) + + +class AsyncUtilityResourceWithStreamingResponse: + def __init__(self, utility: AsyncUtilityResource) -> None: + self._utility = utility + + self.prefetch = async_to_streamed_response_wrapper( + utility.prefetch, + ) + self.prefetch_by_email = async_to_streamed_response_wrapper( + utility.prefetch_by_email, + ) diff --git a/src/context/dev/resources/web.py b/src/context/dev/resources/web.py new file mode 100644 index 0000000..5ba2455 --- /dev/null +++ b/src/context/dev/resources/web.py @@ -0,0 +1,645 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ..types import ( + web_screenshot_params, + web_web_scrape_md_params, + web_web_scrape_html_params, + web_web_scrape_images_params, + web_web_scrape_sitemap_params, +) +from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.web_screenshot_response import WebScreenshotResponse +from ..types.web_web_scrape_md_response import WebWebScrapeMdResponse +from ..types.web_web_scrape_html_response import WebWebScrapeHTMLResponse +from ..types.web_web_scrape_images_response import WebWebScrapeImagesResponse +from ..types.web_web_scrape_sitemap_response import WebWebScrapeSitemapResponse + +__all__ = ["WebResource", "AsyncWebResource"] + + +class WebResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> WebResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return WebResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> WebResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return WebResourceWithStreamingResponse(self) + + def screenshot( + self, + *, + domain: str, + full_screenshot: Literal["true", "false"] | Omit = omit, + page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] | Omit = omit, + prioritize: Literal["speed", "quality"] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebScreenshotResponse: + """Capture a screenshot of a website. + + Supports both viewport (standard browser + view) and full-page screenshots. Can also screenshot specific page types (login, + pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to + the uploaded screenshot image hosted on our CDN. + + Args: + domain: Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The + domain will be automatically normalized and validated. + + full_screenshot: Optional parameter to determine screenshot type. If 'true', takes a full page + screenshot capturing all content. If 'false' or not provided, takes a viewport + screenshot (standard browser view). + + 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 + provided, screenshots the main domain landing page. + + prioritize: Optional parameter to prioritize screenshot capture. If 'speed', optimizes for + faster capture with basic quality. If 'quality', optimizes for higher quality + with longer wait times. Defaults to 'quality' if not provided. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/brand/screenshot", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "domain": domain, + "full_screenshot": full_screenshot, + "page": page, + "prioritize": prioritize, + }, + web_screenshot_params.WebScreenshotParams, + ), + ), + cast_to=WebScreenshotResponse, + ) + + def web_scrape_html( + self, + *, + url: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebWebScrapeHTMLResponse: + """Scrapes the given URL and returns the raw HTML content of the page. + + Uses + automatic proxy escalation to handle blocked sites. + + Args: + url: Full URL to scrape (must include http:// or https:// protocol) + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/web/scrape/html", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"url": url}, web_web_scrape_html_params.WebWebScrapeHTMLParams), + ), + cast_to=WebWebScrapeHTMLResponse, + ) + + def web_scrape_images( + self, + *, + url: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebWebScrapeImagesResponse: + """Scrapes all images from the given URL. + + Extracts images from img, svg, + picture/source, link, and video elements including inline SVGs, base64 data + URIs, and standard URLs. + + Args: + url: Full URL to scrape images from (must include http:// or https:// protocol) + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/web/scrape/images", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"url": url}, web_web_scrape_images_params.WebWebScrapeImagesParams), + ), + cast_to=WebWebScrapeImagesResponse, + ) + + def web_scrape_md( + self, + *, + url: str, + include_images: bool | Omit = omit, + include_links: bool | Omit = omit, + shorten_base64_images: 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebWebScrapeMdResponse: + """ + Scrapes the given URL, converts the HTML content to GitHub Flavored Markdown + (GFM), and returns the result. Uses automatic proxy escalation to handle blocked + sites. + + Args: + url: Full URL to scrape and convert to markdown (must include http:// or https:// + protocol) + + include_images: Include image references in Markdown output + + include_links: Preserve hyperlinks in Markdown output + + shorten_base64_images: Shorten base64-encoded image data in the Markdown output + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/web/scrape/markdown", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "url": url, + "include_images": include_images, + "include_links": include_links, + "shorten_base64_images": shorten_base64_images, + }, + web_web_scrape_md_params.WebWebScrapeMdParams, + ), + ), + cast_to=WebWebScrapeMdResponse, + ) + + def web_scrape_sitemap( + self, + *, + domain: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebWebScrapeSitemapResponse: + """ + Crawls the sitemap of the given domain and returns all discovered page URLs. + Supports sitemap index files (recursive), parallel fetching with concurrency + control, deduplication, and filters out non-page resources (images, PDFs, etc.). + + Args: + domain: Domain name to crawl sitemaps for (e.g., 'example.com'). The domain will be + automatically normalized and validated. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/web/scrape/sitemap", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"domain": domain}, web_web_scrape_sitemap_params.WebWebScrapeSitemapParams), + ), + cast_to=WebWebScrapeSitemapResponse, + ) + + +class AsyncWebResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncWebResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers + """ + return AsyncWebResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncWebResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/brand-dot-dev/context-python-sdk#with_streaming_response + """ + return AsyncWebResourceWithStreamingResponse(self) + + async def screenshot( + self, + *, + domain: str, + full_screenshot: Literal["true", "false"] | Omit = omit, + page: Literal["login", "signup", "blog", "careers", "pricing", "terms", "privacy", "contact"] | Omit = omit, + prioritize: Literal["speed", "quality"] | 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebScreenshotResponse: + """Capture a screenshot of a website. + + Supports both viewport (standard browser + view) and full-page screenshots. Can also screenshot specific page types (login, + pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to + the uploaded screenshot image hosted on our CDN. + + Args: + domain: Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The + domain will be automatically normalized and validated. + + full_screenshot: Optional parameter to determine screenshot type. If 'true', takes a full page + screenshot capturing all content. If 'false' or not provided, takes a viewport + screenshot (standard browser view). + + 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 + provided, screenshots the main domain landing page. + + prioritize: Optional parameter to prioritize screenshot capture. If 'speed', optimizes for + faster capture with basic quality. If 'quality', optimizes for higher quality + with longer wait times. Defaults to 'quality' if not provided. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/brand/screenshot", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "domain": domain, + "full_screenshot": full_screenshot, + "page": page, + "prioritize": prioritize, + }, + web_screenshot_params.WebScreenshotParams, + ), + ), + cast_to=WebScreenshotResponse, + ) + + async def web_scrape_html( + self, + *, + url: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebWebScrapeHTMLResponse: + """Scrapes the given URL and returns the raw HTML content of the page. + + Uses + automatic proxy escalation to handle blocked sites. + + Args: + url: Full URL to scrape (must include http:// or https:// protocol) + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/web/scrape/html", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"url": url}, web_web_scrape_html_params.WebWebScrapeHTMLParams), + ), + cast_to=WebWebScrapeHTMLResponse, + ) + + async def web_scrape_images( + self, + *, + url: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebWebScrapeImagesResponse: + """Scrapes all images from the given URL. + + Extracts images from img, svg, + picture/source, link, and video elements including inline SVGs, base64 data + URIs, and standard URLs. + + Args: + url: Full URL to scrape images from (must include http:// or https:// protocol) + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/web/scrape/images", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"url": url}, web_web_scrape_images_params.WebWebScrapeImagesParams), + ), + cast_to=WebWebScrapeImagesResponse, + ) + + async def web_scrape_md( + self, + *, + url: str, + include_images: bool | Omit = omit, + include_links: bool | Omit = omit, + shorten_base64_images: 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. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebWebScrapeMdResponse: + """ + Scrapes the given URL, converts the HTML content to GitHub Flavored Markdown + (GFM), and returns the result. Uses automatic proxy escalation to handle blocked + sites. + + Args: + url: Full URL to scrape and convert to markdown (must include http:// or https:// + protocol) + + include_images: Include image references in Markdown output + + include_links: Preserve hyperlinks in Markdown output + + shorten_base64_images: Shorten base64-encoded image data in the Markdown output + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/web/scrape/markdown", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "url": url, + "include_images": include_images, + "include_links": include_links, + "shorten_base64_images": shorten_base64_images, + }, + web_web_scrape_md_params.WebWebScrapeMdParams, + ), + ), + cast_to=WebWebScrapeMdResponse, + ) + + async def web_scrape_sitemap( + self, + *, + domain: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> WebWebScrapeSitemapResponse: + """ + Crawls the sitemap of the given domain and returns all discovered page URLs. + Supports sitemap index files (recursive), parallel fetching with concurrency + control, deduplication, and filters out non-page resources (images, PDFs, etc.). + + Args: + domain: Domain name to crawl sitemaps for (e.g., 'example.com'). The domain will be + automatically normalized and validated. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/web/scrape/sitemap", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"domain": domain}, web_web_scrape_sitemap_params.WebWebScrapeSitemapParams + ), + ), + cast_to=WebWebScrapeSitemapResponse, + ) + + +class WebResourceWithRawResponse: + def __init__(self, web: WebResource) -> None: + self._web = web + + self.screenshot = to_raw_response_wrapper( + web.screenshot, + ) + self.web_scrape_html = to_raw_response_wrapper( + web.web_scrape_html, + ) + self.web_scrape_images = to_raw_response_wrapper( + web.web_scrape_images, + ) + self.web_scrape_md = to_raw_response_wrapper( + web.web_scrape_md, + ) + self.web_scrape_sitemap = to_raw_response_wrapper( + web.web_scrape_sitemap, + ) + + +class AsyncWebResourceWithRawResponse: + def __init__(self, web: AsyncWebResource) -> None: + self._web = web + + self.screenshot = async_to_raw_response_wrapper( + web.screenshot, + ) + self.web_scrape_html = async_to_raw_response_wrapper( + web.web_scrape_html, + ) + self.web_scrape_images = async_to_raw_response_wrapper( + web.web_scrape_images, + ) + self.web_scrape_md = async_to_raw_response_wrapper( + web.web_scrape_md, + ) + self.web_scrape_sitemap = async_to_raw_response_wrapper( + web.web_scrape_sitemap, + ) + + +class WebResourceWithStreamingResponse: + def __init__(self, web: WebResource) -> None: + self._web = web + + self.screenshot = to_streamed_response_wrapper( + web.screenshot, + ) + self.web_scrape_html = to_streamed_response_wrapper( + web.web_scrape_html, + ) + self.web_scrape_images = to_streamed_response_wrapper( + web.web_scrape_images, + ) + self.web_scrape_md = to_streamed_response_wrapper( + web.web_scrape_md, + ) + self.web_scrape_sitemap = to_streamed_response_wrapper( + web.web_scrape_sitemap, + ) + + +class AsyncWebResourceWithStreamingResponse: + def __init__(self, web: AsyncWebResource) -> None: + self._web = web + + self.screenshot = async_to_streamed_response_wrapper( + web.screenshot, + ) + self.web_scrape_html = async_to_streamed_response_wrapper( + web.web_scrape_html, + ) + self.web_scrape_images = async_to_streamed_response_wrapper( + web.web_scrape_images, + ) + self.web_scrape_md = async_to_streamed_response_wrapper( + web.web_scrape_md, + ) + self.web_scrape_sitemap = async_to_streamed_response_wrapper( + web.web_scrape_sitemap, + ) diff --git a/src/context/dev/types/__init__.py b/src/context/dev/types/__init__.py index 2b7129d..c485ed5 100644 --- a/src/context/dev/types/__init__.py +++ b/src/context/dev/types/__init__.py @@ -2,44 +2,44 @@ from __future__ import annotations -from .brand_fonts_params import BrandFontsParams as BrandFontsParams -from .brand_fonts_response import BrandFontsResponse as BrandFontsResponse -from .brand_ai_query_params import BrandAIQueryParams as BrandAIQueryParams -from .brand_prefetch_params import BrandPrefetchParams as BrandPrefetchParams +from .ai_ai_query_params import AIAIQueryParams as AIAIQueryParams +from .ai_ai_query_response import AIAIQueryResponse as AIAIQueryResponse from .brand_retrieve_params import BrandRetrieveParams as BrandRetrieveParams -from .brand_ai_product_params import BrandAIProductParams as BrandAIProductParams -from .brand_ai_query_response import BrandAIQueryResponse as BrandAIQueryResponse -from .brand_prefetch_response import BrandPrefetchResponse as BrandPrefetchResponse +from .web_screenshot_params import WebScreenshotParams as WebScreenshotParams from .brand_retrieve_response import BrandRetrieveResponse as BrandRetrieveResponse -from .brand_screenshot_params import BrandScreenshotParams as BrandScreenshotParams -from .brand_styleguide_params import BrandStyleguideParams as BrandStyleguideParams -from .brand_ai_products_params import BrandAIProductsParams as BrandAIProductsParams -from .brand_ai_product_response import BrandAIProductResponse as BrandAIProductResponse -from .brand_screenshot_response import BrandScreenshotResponse as BrandScreenshotResponse -from .brand_styleguide_response import BrandStyleguideResponse as BrandStyleguideResponse -from .brand_ai_products_response import BrandAIProductsResponse as BrandAIProductsResponse -from .brand_web_scrape_md_params import BrandWebScrapeMdParams as BrandWebScrapeMdParams -from .brand_retrieve_naics_params import BrandRetrieveNaicsParams as BrandRetrieveNaicsParams -from .brand_web_scrape_html_params import BrandWebScrapeHTMLParams as BrandWebScrapeHTMLParams -from .brand_web_scrape_md_response import BrandWebScrapeMdResponse as BrandWebScrapeMdResponse +from .utility_prefetch_params import UtilityPrefetchParams as UtilityPrefetchParams +from .web_screenshot_response import WebScreenshotResponse as WebScreenshotResponse +from .web_web_scrape_md_params import WebWebScrapeMdParams as WebWebScrapeMdParams +from .ai_extract_product_params import AIExtractProductParams as AIExtractProductParams +from .utility_prefetch_response import UtilityPrefetchResponse as UtilityPrefetchResponse +from .ai_extract_products_params import AIExtractProductsParams as AIExtractProductsParams +from .style_extract_fonts_params import StyleExtractFontsParams as StyleExtractFontsParams +from .web_web_scrape_html_params import WebWebScrapeHTMLParams as WebWebScrapeHTMLParams +from .web_web_scrape_md_response import WebWebScrapeMdResponse as WebWebScrapeMdResponse +from .ai_extract_product_response import AIExtractProductResponse as AIExtractProductResponse +from .ai_extract_products_response import AIExtractProductsResponse as AIExtractProductsResponse +from .style_extract_fonts_response import StyleExtractFontsResponse as StyleExtractFontsResponse +from .web_web_scrape_html_response import WebWebScrapeHTMLResponse as WebWebScrapeHTMLResponse +from .web_web_scrape_images_params import WebWebScrapeImagesParams as WebWebScrapeImagesParams from .brand_retrieve_by_isin_params import BrandRetrieveByIsinParams as BrandRetrieveByIsinParams from .brand_retrieve_by_name_params import BrandRetrieveByNameParams as BrandRetrieveByNameParams -from .brand_retrieve_naics_response import BrandRetrieveNaicsResponse as BrandRetrieveNaicsResponse -from .brand_prefetch_by_email_params import BrandPrefetchByEmailParams as BrandPrefetchByEmailParams +from .web_web_scrape_sitemap_params import WebWebScrapeSitemapParams as WebWebScrapeSitemapParams from .brand_retrieve_by_email_params import BrandRetrieveByEmailParams as BrandRetrieveByEmailParams -from .brand_web_scrape_html_response import BrandWebScrapeHTMLResponse as BrandWebScrapeHTMLResponse -from .brand_web_scrape_images_params import BrandWebScrapeImagesParams as BrandWebScrapeImagesParams +from .industry_retrieve_naics_params import IndustryRetrieveNaicsParams as IndustryRetrieveNaicsParams +from .web_web_scrape_images_response import WebWebScrapeImagesResponse as WebWebScrapeImagesResponse from .brand_retrieve_by_isin_response import BrandRetrieveByIsinResponse as BrandRetrieveByIsinResponse from .brand_retrieve_by_name_response import BrandRetrieveByNameResponse as BrandRetrieveByNameResponse from .brand_retrieve_by_ticker_params import BrandRetrieveByTickerParams as BrandRetrieveByTickerParams -from .brand_web_scrape_sitemap_params import BrandWebScrapeSitemapParams as BrandWebScrapeSitemapParams -from .brand_prefetch_by_email_response import BrandPrefetchByEmailResponse as BrandPrefetchByEmailResponse +from .style_extract_styleguide_params import StyleExtractStyleguideParams as StyleExtractStyleguideParams +from .web_web_scrape_sitemap_response import WebWebScrapeSitemapResponse as WebWebScrapeSitemapResponse from .brand_retrieve_by_email_response import BrandRetrieveByEmailResponse as BrandRetrieveByEmailResponse from .brand_retrieve_simplified_params import BrandRetrieveSimplifiedParams as BrandRetrieveSimplifiedParams -from .brand_web_scrape_images_response import BrandWebScrapeImagesResponse as BrandWebScrapeImagesResponse +from .industry_retrieve_naics_response import IndustryRetrieveNaicsResponse as IndustryRetrieveNaicsResponse +from .utility_prefetch_by_email_params import UtilityPrefetchByEmailParams as UtilityPrefetchByEmailParams from .brand_retrieve_by_ticker_response import BrandRetrieveByTickerResponse as BrandRetrieveByTickerResponse -from .brand_web_scrape_sitemap_response import BrandWebScrapeSitemapResponse as BrandWebScrapeSitemapResponse +from .style_extract_styleguide_response import StyleExtractStyleguideResponse as StyleExtractStyleguideResponse from .brand_retrieve_simplified_response import BrandRetrieveSimplifiedResponse as BrandRetrieveSimplifiedResponse +from .utility_prefetch_by_email_response import UtilityPrefetchByEmailResponse as UtilityPrefetchByEmailResponse from .brand_identify_from_transaction_params import ( BrandIdentifyFromTransactionParams as BrandIdentifyFromTransactionParams, ) diff --git a/src/context/dev/types/brand_ai_query_params.py b/src/context/dev/types/ai_ai_query_params.py similarity index 95% rename from src/context/dev/types/brand_ai_query_params.py rename to src/context/dev/types/ai_ai_query_params.py index d45a821..dd21b8e 100644 --- a/src/context/dev/types/brand_ai_query_params.py +++ b/src/context/dev/types/ai_ai_query_params.py @@ -7,10 +7,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandAIQueryParams", "DataToExtract", "SpecificPages"] +__all__ = ["AIAIQueryParams", "DataToExtract", "SpecificPages"] -class BrandAIQueryParams(TypedDict, total=False): +class AIAIQueryParams(TypedDict, total=False): data_to_extract: Required[Iterable[DataToExtract]] """Array of data points to extract from the website""" diff --git a/src/context/dev/types/brand_ai_query_response.py b/src/context/dev/types/ai_ai_query_response.py similarity index 90% rename from src/context/dev/types/brand_ai_query_response.py rename to src/context/dev/types/ai_ai_query_response.py index 9971458..1c49c53 100644 --- a/src/context/dev/types/brand_ai_query_response.py +++ b/src/context/dev/types/ai_ai_query_response.py @@ -4,7 +4,7 @@ from .._models import BaseModel -__all__ = ["BrandAIQueryResponse", "DataExtracted"] +__all__ = ["AIAIQueryResponse", "DataExtracted"] class DataExtracted(BaseModel): @@ -19,7 +19,7 @@ class DataExtracted(BaseModel): """ -class BrandAIQueryResponse(BaseModel): +class AIAIQueryResponse(BaseModel): data_extracted: Optional[List[DataExtracted]] = None """Array of extracted data points""" diff --git a/src/context/dev/types/brand_ai_product_params.py b/src/context/dev/types/ai_extract_product_params.py similarity index 84% rename from src/context/dev/types/brand_ai_product_params.py rename to src/context/dev/types/ai_extract_product_params.py index 17e62c9..b570411 100644 --- a/src/context/dev/types/brand_ai_product_params.py +++ b/src/context/dev/types/ai_extract_product_params.py @@ -6,10 +6,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandAIProductParams"] +__all__ = ["AIExtractProductParams"] -class BrandAIProductParams(TypedDict, total=False): +class AIExtractProductParams(TypedDict, total=False): url: Required[str] """The product page URL to extract product data from.""" diff --git a/src/context/dev/types/brand_ai_product_response.py b/src/context/dev/types/ai_extract_product_response.py similarity index 94% rename from src/context/dev/types/brand_ai_product_response.py rename to src/context/dev/types/ai_extract_product_response.py index eb31de2..b2db947 100644 --- a/src/context/dev/types/brand_ai_product_response.py +++ b/src/context/dev/types/ai_extract_product_response.py @@ -5,7 +5,7 @@ from .._models import BaseModel -__all__ = ["BrandAIProductResponse", "Product"] +__all__ = ["AIExtractProductResponse", "Product"] class Product(BaseModel): @@ -51,7 +51,7 @@ class Product(BaseModel): """URL to the product page""" -class BrandAIProductResponse(BaseModel): +class AIExtractProductResponse(BaseModel): is_product_page: Optional[bool] = None """Whether the given URL is a product detail page""" diff --git a/src/context/dev/types/brand_ai_products_params.py b/src/context/dev/types/ai_extract_products_params.py similarity index 90% rename from src/context/dev/types/brand_ai_products_params.py rename to src/context/dev/types/ai_extract_products_params.py index 9a61efe..1aaa868 100644 --- a/src/context/dev/types/brand_ai_products_params.py +++ b/src/context/dev/types/ai_extract_products_params.py @@ -7,7 +7,7 @@ from .._utils import PropertyInfo -__all__ = ["BrandAIProductsParams", "ByDomain", "ByDirectURL"] +__all__ = ["AIExtractProductsParams", "ByDomain", "ByDirectURL"] class ByDomain(TypedDict, total=False): @@ -41,4 +41,4 @@ class ByDirectURL(TypedDict, total=False): """ -BrandAIProductsParams: TypeAlias = Union[ByDomain, ByDirectURL] +AIExtractProductsParams: TypeAlias = Union[ByDomain, ByDirectURL] diff --git a/src/context/dev/types/brand_ai_products_response.py b/src/context/dev/types/ai_extract_products_response.py similarity index 93% rename from src/context/dev/types/brand_ai_products_response.py rename to src/context/dev/types/ai_extract_products_response.py index 4100a1a..5cb7f2f 100644 --- a/src/context/dev/types/brand_ai_products_response.py +++ b/src/context/dev/types/ai_extract_products_response.py @@ -5,7 +5,7 @@ from .._models import BaseModel -__all__ = ["BrandAIProductsResponse", "Product"] +__all__ = ["AIExtractProductsResponse", "Product"] class Product(BaseModel): @@ -49,6 +49,6 @@ class Product(BaseModel): """URL to the product page""" -class BrandAIProductsResponse(BaseModel): +class AIExtractProductsResponse(BaseModel): products: Optional[List[Product]] = None """Array of products extracted from the website""" diff --git a/src/context/dev/types/brand_identify_from_transaction_params.py b/src/context/dev/types/brand_identify_from_transaction_params.py index bc46c8f..e04b1e5 100644 --- a/src/context/dev/types/brand_identify_from_transaction_params.py +++ b/src/context/dev/types/brand_identify_from_transaction_params.py @@ -268,6 +268,7 @@ class BrandIdentifyFromTransactionParams(TypedDict, total=False): "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -287,6 +288,7 @@ class BrandIdentifyFromTransactionParams(TypedDict, total=False): "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -309,6 +311,7 @@ class BrandIdentifyFromTransactionParams(TypedDict, total=False): "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", diff --git a/src/context/dev/types/brand_retrieve_by_email_params.py b/src/context/dev/types/brand_retrieve_by_email_params.py index da361c6..886c213 100644 --- a/src/context/dev/types/brand_retrieve_by_email_params.py +++ b/src/context/dev/types/brand_retrieve_by_email_params.py @@ -23,6 +23,7 @@ class BrandRetrieveByEmailParams(TypedDict, total=False): "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -42,6 +43,7 @@ class BrandRetrieveByEmailParams(TypedDict, total=False): "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -64,6 +66,7 @@ class BrandRetrieveByEmailParams(TypedDict, total=False): "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", diff --git a/src/context/dev/types/brand_retrieve_by_isin_params.py b/src/context/dev/types/brand_retrieve_by_isin_params.py index db2731b..db559fa 100644 --- a/src/context/dev/types/brand_retrieve_by_isin_params.py +++ b/src/context/dev/types/brand_retrieve_by_isin_params.py @@ -23,6 +23,7 @@ class BrandRetrieveByIsinParams(TypedDict, total=False): "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -42,6 +43,7 @@ class BrandRetrieveByIsinParams(TypedDict, total=False): "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -64,6 +66,7 @@ class BrandRetrieveByIsinParams(TypedDict, total=False): "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", diff --git a/src/context/dev/types/brand_retrieve_by_name_params.py b/src/context/dev/types/brand_retrieve_by_name_params.py index 542f481..847bdb3 100644 --- a/src/context/dev/types/brand_retrieve_by_name_params.py +++ b/src/context/dev/types/brand_retrieve_by_name_params.py @@ -268,6 +268,7 @@ class BrandRetrieveByNameParams(TypedDict, total=False): "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -287,6 +288,7 @@ class BrandRetrieveByNameParams(TypedDict, total=False): "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -309,6 +311,7 @@ class BrandRetrieveByNameParams(TypedDict, total=False): "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", diff --git a/src/context/dev/types/brand_retrieve_by_ticker_params.py b/src/context/dev/types/brand_retrieve_by_ticker_params.py index 4bbdb2f..d328385 100644 --- a/src/context/dev/types/brand_retrieve_by_ticker_params.py +++ b/src/context/dev/types/brand_retrieve_by_ticker_params.py @@ -22,6 +22,7 @@ class BrandRetrieveByTickerParams(TypedDict, total=False): "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -41,6 +42,7 @@ class BrandRetrieveByTickerParams(TypedDict, total=False): "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -63,6 +65,7 @@ class BrandRetrieveByTickerParams(TypedDict, total=False): "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", diff --git a/src/context/dev/types/brand_retrieve_params.py b/src/context/dev/types/brand_retrieve_params.py index 5091652..03e102a 100644 --- a/src/context/dev/types/brand_retrieve_params.py +++ b/src/context/dev/types/brand_retrieve_params.py @@ -22,6 +22,7 @@ class BrandRetrieveParams(TypedDict, total=False): "azeri", "bengali", "bulgarian", + "cantonese", "cebuano", "croatian", "czech", @@ -41,6 +42,7 @@ class BrandRetrieveParams(TypedDict, total=False): "indonesian", "italian", "kazakh", + "korean", "kyrgyz", "latin", "latvian", @@ -63,6 +65,7 @@ class BrandRetrieveParams(TypedDict, total=False): "swahili", "swedish", "tagalog", + "thai", "turkish", "ukrainian", "urdu", diff --git a/src/context/dev/types/brand_retrieve_naics_params.py b/src/context/dev/types/industry_retrieve_naics_params.py similarity index 91% rename from src/context/dev/types/brand_retrieve_naics_params.py rename to src/context/dev/types/industry_retrieve_naics_params.py index 2803c13..cbaed87 100644 --- a/src/context/dev/types/brand_retrieve_naics_params.py +++ b/src/context/dev/types/industry_retrieve_naics_params.py @@ -6,10 +6,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandRetrieveNaicsParams"] +__all__ = ["IndustryRetrieveNaicsParams"] -class BrandRetrieveNaicsParams(TypedDict, total=False): +class IndustryRetrieveNaicsParams(TypedDict, total=False): input: Required[str] """Brand domain or title to retrieve NAICS code for. diff --git a/src/context/dev/types/brand_retrieve_naics_response.py b/src/context/dev/types/industry_retrieve_naics_response.py similarity index 88% rename from src/context/dev/types/brand_retrieve_naics_response.py rename to src/context/dev/types/industry_retrieve_naics_response.py index a53da5e..bcfc2ad 100644 --- a/src/context/dev/types/brand_retrieve_naics_response.py +++ b/src/context/dev/types/industry_retrieve_naics_response.py @@ -5,7 +5,7 @@ from .._models import BaseModel -__all__ = ["BrandRetrieveNaicsResponse", "Code"] +__all__ = ["IndustryRetrieveNaicsResponse", "Code"] class Code(BaseModel): @@ -19,7 +19,7 @@ class Code(BaseModel): """NAICS title""" -class BrandRetrieveNaicsResponse(BaseModel): +class IndustryRetrieveNaicsResponse(BaseModel): codes: Optional[List[Code]] = None """Array of NAICS codes and titles.""" diff --git a/src/context/dev/types/brand_fonts_params.py b/src/context/dev/types/style_extract_fonts_params.py similarity index 87% rename from src/context/dev/types/brand_fonts_params.py rename to src/context/dev/types/style_extract_fonts_params.py index db13d2f..178f6f3 100644 --- a/src/context/dev/types/brand_fonts_params.py +++ b/src/context/dev/types/style_extract_fonts_params.py @@ -6,10 +6,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandFontsParams"] +__all__ = ["StyleExtractFontsParams"] -class BrandFontsParams(TypedDict, total=False): +class StyleExtractFontsParams(TypedDict, total=False): domain: Required[str] """Domain name to extract fonts from (e.g., 'example.com', 'google.com'). diff --git a/src/context/dev/types/brand_fonts_response.py b/src/context/dev/types/style_extract_fonts_response.py similarity index 90% rename from src/context/dev/types/brand_fonts_response.py rename to src/context/dev/types/style_extract_fonts_response.py index 2721af9..ab00e10 100644 --- a/src/context/dev/types/brand_fonts_response.py +++ b/src/context/dev/types/style_extract_fonts_response.py @@ -4,7 +4,7 @@ from .._models import BaseModel -__all__ = ["BrandFontsResponse", "Font"] +__all__ = ["StyleExtractFontsResponse", "Font"] class Font(BaseModel): @@ -30,7 +30,7 @@ class Font(BaseModel): """Array of CSS selectors or element types where this font is used""" -class BrandFontsResponse(BaseModel): +class StyleExtractFontsResponse(BaseModel): code: int """HTTP status code, e.g., 200""" diff --git a/src/context/dev/types/brand_styleguide_params.py b/src/context/dev/types/style_extract_styleguide_params.py similarity index 92% rename from src/context/dev/types/brand_styleguide_params.py rename to src/context/dev/types/style_extract_styleguide_params.py index e97cf77..c338cb6 100644 --- a/src/context/dev/types/brand_styleguide_params.py +++ b/src/context/dev/types/style_extract_styleguide_params.py @@ -6,10 +6,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandStyleguideParams"] +__all__ = ["StyleExtractStyleguideParams"] -class BrandStyleguideParams(TypedDict, total=False): +class StyleExtractStyleguideParams(TypedDict, total=False): direct_url: Annotated[str, PropertyInfo(alias="directUrl")] """ A specific URL to fetch the styleguide from directly, bypassing domain diff --git a/src/context/dev/types/brand_styleguide_response.py b/src/context/dev/types/style_extract_styleguide_response.py similarity index 99% rename from src/context/dev/types/brand_styleguide_response.py rename to src/context/dev/types/style_extract_styleguide_response.py index 35b51b3..56ef048 100644 --- a/src/context/dev/types/brand_styleguide_response.py +++ b/src/context/dev/types/style_extract_styleguide_response.py @@ -8,7 +8,7 @@ from .._models import BaseModel __all__ = [ - "BrandStyleguideResponse", + "StyleExtractStyleguideResponse", "Styleguide", "StyleguideColors", "StyleguideComponents", @@ -307,7 +307,7 @@ class Styleguide(BaseModel): """Typography styles used on the website""" -class BrandStyleguideResponse(BaseModel): +class StyleExtractStyleguideResponse(BaseModel): code: Optional[int] = None """HTTP status code""" diff --git a/src/context/dev/types/brand_prefetch_by_email_params.py b/src/context/dev/types/utility_prefetch_by_email_params.py similarity index 87% rename from src/context/dev/types/brand_prefetch_by_email_params.py rename to src/context/dev/types/utility_prefetch_by_email_params.py index ec7cc6f..b9a36a8 100644 --- a/src/context/dev/types/brand_prefetch_by_email_params.py +++ b/src/context/dev/types/utility_prefetch_by_email_params.py @@ -6,10 +6,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandPrefetchByEmailParams"] +__all__ = ["UtilityPrefetchByEmailParams"] -class BrandPrefetchByEmailParams(TypedDict, total=False): +class UtilityPrefetchByEmailParams(TypedDict, total=False): email: Required[str] """Email address to prefetch brand data for. diff --git a/src/context/dev/types/brand_prefetch_by_email_response.py b/src/context/dev/types/utility_prefetch_by_email_response.py similarity index 80% rename from src/context/dev/types/brand_prefetch_by_email_response.py rename to src/context/dev/types/utility_prefetch_by_email_response.py index c117f7d..7061284 100644 --- a/src/context/dev/types/brand_prefetch_by_email_response.py +++ b/src/context/dev/types/utility_prefetch_by_email_response.py @@ -4,10 +4,10 @@ from .._models import BaseModel -__all__ = ["BrandPrefetchByEmailResponse"] +__all__ = ["UtilityPrefetchByEmailResponse"] -class BrandPrefetchByEmailResponse(BaseModel): +class UtilityPrefetchByEmailResponse(BaseModel): domain: Optional[str] = None """The domain that was queued for prefetching""" diff --git a/src/context/dev/types/brand_prefetch_params.py b/src/context/dev/types/utility_prefetch_params.py similarity index 86% rename from src/context/dev/types/brand_prefetch_params.py rename to src/context/dev/types/utility_prefetch_params.py index 02c13f6..51993af 100644 --- a/src/context/dev/types/brand_prefetch_params.py +++ b/src/context/dev/types/utility_prefetch_params.py @@ -6,10 +6,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandPrefetchParams"] +__all__ = ["UtilityPrefetchParams"] -class BrandPrefetchParams(TypedDict, total=False): +class UtilityPrefetchParams(TypedDict, total=False): domain: Required[str] """Domain name to prefetch brand data for""" diff --git a/src/context/dev/types/brand_prefetch_response.py b/src/context/dev/types/utility_prefetch_response.py similarity index 82% rename from src/context/dev/types/brand_prefetch_response.py rename to src/context/dev/types/utility_prefetch_response.py index 4995856..b99a78d 100644 --- a/src/context/dev/types/brand_prefetch_response.py +++ b/src/context/dev/types/utility_prefetch_response.py @@ -4,10 +4,10 @@ from .._models import BaseModel -__all__ = ["BrandPrefetchResponse"] +__all__ = ["UtilityPrefetchResponse"] -class BrandPrefetchResponse(BaseModel): +class UtilityPrefetchResponse(BaseModel): domain: Optional[str] = None """The domain that was queued for prefetching""" diff --git a/src/context/dev/types/brand_screenshot_params.py b/src/context/dev/types/web_screenshot_params.py similarity index 94% rename from src/context/dev/types/brand_screenshot_params.py rename to src/context/dev/types/web_screenshot_params.py index 4f26b1f..000ff23 100644 --- a/src/context/dev/types/brand_screenshot_params.py +++ b/src/context/dev/types/web_screenshot_params.py @@ -6,10 +6,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandScreenshotParams"] +__all__ = ["WebScreenshotParams"] -class BrandScreenshotParams(TypedDict, total=False): +class WebScreenshotParams(TypedDict, total=False): domain: Required[str] """Domain name to take screenshot of (e.g., 'example.com', 'google.com'). diff --git a/src/context/dev/types/brand_screenshot_response.py b/src/context/dev/types/web_screenshot_response.py similarity index 89% rename from src/context/dev/types/brand_screenshot_response.py rename to src/context/dev/types/web_screenshot_response.py index c43ae74..e81a5b2 100644 --- a/src/context/dev/types/brand_screenshot_response.py +++ b/src/context/dev/types/web_screenshot_response.py @@ -7,10 +7,10 @@ from .._models import BaseModel -__all__ = ["BrandScreenshotResponse"] +__all__ = ["WebScreenshotResponse"] -class BrandScreenshotResponse(BaseModel): +class WebScreenshotResponse(BaseModel): code: Optional[int] = None """HTTP status code""" diff --git a/src/context/dev/types/brand_web_scrape_html_params.py b/src/context/dev/types/web_web_scrape_html_params.py similarity index 74% rename from src/context/dev/types/brand_web_scrape_html_params.py rename to src/context/dev/types/web_web_scrape_html_params.py index 86246f4..1847d07 100644 --- a/src/context/dev/types/brand_web_scrape_html_params.py +++ b/src/context/dev/types/web_web_scrape_html_params.py @@ -4,9 +4,9 @@ from typing_extensions import Required, TypedDict -__all__ = ["BrandWebScrapeHTMLParams"] +__all__ = ["WebWebScrapeHTMLParams"] -class BrandWebScrapeHTMLParams(TypedDict, total=False): +class WebWebScrapeHTMLParams(TypedDict, total=False): url: Required[str] """Full URL to scrape (must include http:// or https:// protocol)""" diff --git a/src/context/dev/types/brand_web_scrape_html_response.py b/src/context/dev/types/web_web_scrape_html_response.py similarity index 78% rename from src/context/dev/types/brand_web_scrape_html_response.py rename to src/context/dev/types/web_web_scrape_html_response.py index a33cb79..f96ef12 100644 --- a/src/context/dev/types/brand_web_scrape_html_response.py +++ b/src/context/dev/types/web_web_scrape_html_response.py @@ -4,10 +4,10 @@ from .._models import BaseModel -__all__ = ["BrandWebScrapeHTMLResponse"] +__all__ = ["WebWebScrapeHTMLResponse"] -class BrandWebScrapeHTMLResponse(BaseModel): +class WebWebScrapeHTMLResponse(BaseModel): html: str """Raw HTML content of the page""" diff --git a/src/context/dev/types/brand_web_scrape_images_params.py b/src/context/dev/types/web_web_scrape_images_params.py similarity index 74% rename from src/context/dev/types/brand_web_scrape_images_params.py rename to src/context/dev/types/web_web_scrape_images_params.py index 665c5f0..9e89207 100644 --- a/src/context/dev/types/brand_web_scrape_images_params.py +++ b/src/context/dev/types/web_web_scrape_images_params.py @@ -4,9 +4,9 @@ from typing_extensions import Required, TypedDict -__all__ = ["BrandWebScrapeImagesParams"] +__all__ = ["WebWebScrapeImagesParams"] -class BrandWebScrapeImagesParams(TypedDict, total=False): +class WebWebScrapeImagesParams(TypedDict, total=False): url: Required[str] """Full URL to scrape images from (must include http:// or https:// protocol)""" diff --git a/src/context/dev/types/brand_web_scrape_images_response.py b/src/context/dev/types/web_web_scrape_images_response.py similarity index 88% rename from src/context/dev/types/brand_web_scrape_images_response.py rename to src/context/dev/types/web_web_scrape_images_response.py index e97d79a..26d8fce 100644 --- a/src/context/dev/types/brand_web_scrape_images_response.py +++ b/src/context/dev/types/web_web_scrape_images_response.py @@ -5,7 +5,7 @@ from .._models import BaseModel -__all__ = ["BrandWebScrapeImagesResponse", "Image"] +__all__ = ["WebWebScrapeImagesResponse", "Image"] class Image(BaseModel): @@ -22,7 +22,7 @@ class Image(BaseModel): """The type/format of the src value""" -class BrandWebScrapeImagesResponse(BaseModel): +class WebWebScrapeImagesResponse(BaseModel): images: List[Image] """Array of scraped images""" diff --git a/src/context/dev/types/brand_web_scrape_md_params.py b/src/context/dev/types/web_web_scrape_md_params.py similarity index 89% rename from src/context/dev/types/brand_web_scrape_md_params.py rename to src/context/dev/types/web_web_scrape_md_params.py index bf8c2e1..28765b0 100644 --- a/src/context/dev/types/brand_web_scrape_md_params.py +++ b/src/context/dev/types/web_web_scrape_md_params.py @@ -6,10 +6,10 @@ from .._utils import PropertyInfo -__all__ = ["BrandWebScrapeMdParams"] +__all__ = ["WebWebScrapeMdParams"] -class BrandWebScrapeMdParams(TypedDict, total=False): +class WebWebScrapeMdParams(TypedDict, total=False): url: Required[str] """ Full URL to scrape and convert to markdown (must include http:// or https:// diff --git a/src/context/dev/types/brand_web_scrape_md_response.py b/src/context/dev/types/web_web_scrape_md_response.py similarity index 80% rename from src/context/dev/types/brand_web_scrape_md_response.py rename to src/context/dev/types/web_web_scrape_md_response.py index 5161243..f99b67c 100644 --- a/src/context/dev/types/brand_web_scrape_md_response.py +++ b/src/context/dev/types/web_web_scrape_md_response.py @@ -4,10 +4,10 @@ from .._models import BaseModel -__all__ = ["BrandWebScrapeMdResponse"] +__all__ = ["WebWebScrapeMdResponse"] -class BrandWebScrapeMdResponse(BaseModel): +class WebWebScrapeMdResponse(BaseModel): markdown: str """Page content converted to GitHub Flavored Markdown""" diff --git a/src/context/dev/types/brand_web_scrape_sitemap_params.py b/src/context/dev/types/web_web_scrape_sitemap_params.py similarity index 76% rename from src/context/dev/types/brand_web_scrape_sitemap_params.py rename to src/context/dev/types/web_web_scrape_sitemap_params.py index a250097..2ad3d83 100644 --- a/src/context/dev/types/brand_web_scrape_sitemap_params.py +++ b/src/context/dev/types/web_web_scrape_sitemap_params.py @@ -4,10 +4,10 @@ from typing_extensions import Required, TypedDict -__all__ = ["BrandWebScrapeSitemapParams"] +__all__ = ["WebWebScrapeSitemapParams"] -class BrandWebScrapeSitemapParams(TypedDict, total=False): +class WebWebScrapeSitemapParams(TypedDict, total=False): domain: Required[str] """Domain name to crawl sitemaps for (e.g., 'example.com'). diff --git a/src/context/dev/types/brand_web_scrape_sitemap_response.py b/src/context/dev/types/web_web_scrape_sitemap_response.py similarity index 91% rename from src/context/dev/types/brand_web_scrape_sitemap_response.py rename to src/context/dev/types/web_web_scrape_sitemap_response.py index ae7562e..7bd55bf 100644 --- a/src/context/dev/types/brand_web_scrape_sitemap_response.py +++ b/src/context/dev/types/web_web_scrape_sitemap_response.py @@ -7,7 +7,7 @@ from .._models import BaseModel -__all__ = ["BrandWebScrapeSitemapResponse", "Meta"] +__all__ = ["WebWebScrapeSitemapResponse", "Meta"] class Meta(BaseModel): @@ -26,7 +26,7 @@ class Meta(BaseModel): """Number of sitemap files skipped (due to errors, timeouts, or limits)""" -class BrandWebScrapeSitemapResponse(BaseModel): +class WebWebScrapeSitemapResponse(BaseModel): domain: str """The normalized domain that was crawled""" diff --git a/tests/api_resources/test_ai.py b/tests/api_resources/test_ai.py new file mode 100644 index 0000000..8dd7e51 --- /dev/null +++ b/tests/api_resources/test_ai.py @@ -0,0 +1,472 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from context.dev import ContextDev, AsyncContextDev +from tests.utils import assert_matches_type +from context.dev.types import ( + AIAIQueryResponse, + AIExtractProductResponse, + AIExtractProductsResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAI: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_ai_query(self, client: ContextDev) -> None: + ai = client.ai.ai_query( + data_to_extract=[ + { + "datapoint_description": "datapoint_description", + "datapoint_example": "datapoint_example", + "datapoint_name": "datapoint_name", + "datapoint_type": "text", + } + ], + domain="domain", + ) + assert_matches_type(AIAIQueryResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_ai_query_with_all_params(self, client: ContextDev) -> None: + ai = client.ai.ai_query( + data_to_extract=[ + { + "datapoint_description": "datapoint_description", + "datapoint_example": "datapoint_example", + "datapoint_name": "datapoint_name", + "datapoint_type": "text", + "datapoint_list_type": "string", + "datapoint_object_schema": { + "testimonial_text": "string", + "testimonial_author": "string", + }, + } + ], + domain="domain", + specific_pages={ + "about_us": True, + "blog": True, + "careers": True, + "contact_us": True, + "faq": True, + "home_page": True, + "pricing": True, + "privacy_policy": True, + "terms_and_conditions": True, + }, + timeout_ms=1000, + ) + assert_matches_type(AIAIQueryResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_ai_query(self, client: ContextDev) -> None: + response = client.ai.with_raw_response.ai_query( + data_to_extract=[ + { + "datapoint_description": "datapoint_description", + "datapoint_example": "datapoint_example", + "datapoint_name": "datapoint_name", + "datapoint_type": "text", + } + ], + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ai = response.parse() + assert_matches_type(AIAIQueryResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_ai_query(self, client: ContextDev) -> None: + with client.ai.with_streaming_response.ai_query( + data_to_extract=[ + { + "datapoint_description": "datapoint_description", + "datapoint_example": "datapoint_example", + "datapoint_name": "datapoint_name", + "datapoint_type": "text", + } + ], + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ai = response.parse() + assert_matches_type(AIAIQueryResponse, ai, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_product(self, client: ContextDev) -> None: + ai = client.ai.extract_product( + url="https://example.com", + ) + assert_matches_type(AIExtractProductResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_product_with_all_params(self, client: ContextDev) -> None: + ai = client.ai.extract_product( + url="https://example.com", + timeout_ms=1000, + ) + assert_matches_type(AIExtractProductResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_extract_product(self, client: ContextDev) -> None: + response = client.ai.with_raw_response.extract_product( + url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ai = response.parse() + assert_matches_type(AIExtractProductResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_extract_product(self, client: ContextDev) -> None: + with client.ai.with_streaming_response.extract_product( + url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ai = response.parse() + assert_matches_type(AIExtractProductResponse, ai, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_products_overload_1(self, client: ContextDev) -> None: + ai = client.ai.extract_products( + domain="domain", + ) + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_products_with_all_params_overload_1(self, client: ContextDev) -> None: + ai = client.ai.extract_products( + domain="domain", + max_products=1, + timeout_ms=1000, + ) + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_extract_products_overload_1(self, client: ContextDev) -> None: + response = client.ai.with_raw_response.extract_products( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ai = response.parse() + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_extract_products_overload_1(self, client: ContextDev) -> None: + with client.ai.with_streaming_response.extract_products( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ai = response.parse() + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_products_overload_2(self, client: ContextDev) -> None: + ai = client.ai.extract_products( + direct_url="https://example.com", + ) + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_products_with_all_params_overload_2(self, client: ContextDev) -> None: + ai = client.ai.extract_products( + direct_url="https://example.com", + max_products=1, + timeout_ms=1000, + ) + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_extract_products_overload_2(self, client: ContextDev) -> None: + response = client.ai.with_raw_response.extract_products( + direct_url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ai = response.parse() + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_extract_products_overload_2(self, client: ContextDev) -> None: + with client.ai.with_streaming_response.extract_products( + direct_url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ai = response.parse() + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncAI: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_ai_query(self, async_client: AsyncContextDev) -> None: + ai = await async_client.ai.ai_query( + data_to_extract=[ + { + "datapoint_description": "datapoint_description", + "datapoint_example": "datapoint_example", + "datapoint_name": "datapoint_name", + "datapoint_type": "text", + } + ], + domain="domain", + ) + assert_matches_type(AIAIQueryResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_ai_query_with_all_params(self, async_client: AsyncContextDev) -> None: + ai = await async_client.ai.ai_query( + data_to_extract=[ + { + "datapoint_description": "datapoint_description", + "datapoint_example": "datapoint_example", + "datapoint_name": "datapoint_name", + "datapoint_type": "text", + "datapoint_list_type": "string", + "datapoint_object_schema": { + "testimonial_text": "string", + "testimonial_author": "string", + }, + } + ], + domain="domain", + specific_pages={ + "about_us": True, + "blog": True, + "careers": True, + "contact_us": True, + "faq": True, + "home_page": True, + "pricing": True, + "privacy_policy": True, + "terms_and_conditions": True, + }, + timeout_ms=1000, + ) + assert_matches_type(AIAIQueryResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_ai_query(self, async_client: AsyncContextDev) -> None: + response = await async_client.ai.with_raw_response.ai_query( + data_to_extract=[ + { + "datapoint_description": "datapoint_description", + "datapoint_example": "datapoint_example", + "datapoint_name": "datapoint_name", + "datapoint_type": "text", + } + ], + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ai = await response.parse() + assert_matches_type(AIAIQueryResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_ai_query(self, async_client: AsyncContextDev) -> None: + async with async_client.ai.with_streaming_response.ai_query( + data_to_extract=[ + { + "datapoint_description": "datapoint_description", + "datapoint_example": "datapoint_example", + "datapoint_name": "datapoint_name", + "datapoint_type": "text", + } + ], + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ai = await response.parse() + assert_matches_type(AIAIQueryResponse, ai, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_product(self, async_client: AsyncContextDev) -> None: + ai = await async_client.ai.extract_product( + url="https://example.com", + ) + assert_matches_type(AIExtractProductResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_product_with_all_params(self, async_client: AsyncContextDev) -> None: + ai = await async_client.ai.extract_product( + url="https://example.com", + timeout_ms=1000, + ) + assert_matches_type(AIExtractProductResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_extract_product(self, async_client: AsyncContextDev) -> None: + response = await async_client.ai.with_raw_response.extract_product( + url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ai = await response.parse() + assert_matches_type(AIExtractProductResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_extract_product(self, async_client: AsyncContextDev) -> None: + async with async_client.ai.with_streaming_response.extract_product( + url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ai = await response.parse() + assert_matches_type(AIExtractProductResponse, ai, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_products_overload_1(self, async_client: AsyncContextDev) -> None: + ai = await async_client.ai.extract_products( + domain="domain", + ) + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_products_with_all_params_overload_1(self, async_client: AsyncContextDev) -> None: + ai = await async_client.ai.extract_products( + domain="domain", + max_products=1, + timeout_ms=1000, + ) + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_extract_products_overload_1(self, async_client: AsyncContextDev) -> None: + response = await async_client.ai.with_raw_response.extract_products( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ai = await response.parse() + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_extract_products_overload_1(self, async_client: AsyncContextDev) -> None: + async with async_client.ai.with_streaming_response.extract_products( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ai = await response.parse() + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_products_overload_2(self, async_client: AsyncContextDev) -> None: + ai = await async_client.ai.extract_products( + direct_url="https://example.com", + ) + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_products_with_all_params_overload_2(self, async_client: AsyncContextDev) -> None: + ai = await async_client.ai.extract_products( + direct_url="https://example.com", + max_products=1, + timeout_ms=1000, + ) + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_extract_products_overload_2(self, async_client: AsyncContextDev) -> None: + response = await async_client.ai.with_raw_response.extract_products( + direct_url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ai = await response.parse() + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_extract_products_overload_2(self, async_client: AsyncContextDev) -> None: + async with async_client.ai.with_streaming_response.extract_products( + direct_url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ai = await response.parse() + assert_matches_type(AIExtractProductsResponse, ai, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_brand.py b/tests/api_resources/test_brand.py index 1a4bc80..f02f01e 100644 --- a/tests/api_resources/test_brand.py +++ b/tests/api_resources/test_brand.py @@ -10,24 +10,11 @@ from context.dev import ContextDev, AsyncContextDev from tests.utils import assert_matches_type from context.dev.types import ( - BrandFontsResponse, - BrandAIQueryResponse, - BrandPrefetchResponse, BrandRetrieveResponse, - BrandAIProductResponse, - BrandAIProductsResponse, - BrandScreenshotResponse, - BrandStyleguideResponse, - BrandWebScrapeMdResponse, - BrandRetrieveNaicsResponse, - BrandWebScrapeHTMLResponse, BrandRetrieveByIsinResponse, BrandRetrieveByNameResponse, - BrandPrefetchByEmailResponse, BrandRetrieveByEmailResponse, - BrandWebScrapeImagesResponse, BrandRetrieveByTickerResponse, - BrandWebScrapeSitemapResponse, BrandRetrieveSimplifiedResponse, BrandIdentifyFromTransactionResponse, ) @@ -83,271 +70,6 @@ def test_streaming_response_retrieve(self, client: ContextDev) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_ai_product(self, client: ContextDev) -> None: - brand = client.brand.ai_product( - url="https://example.com", - ) - assert_matches_type(BrandAIProductResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_ai_product_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.ai_product( - url="https://example.com", - timeout_ms=1000, - ) - assert_matches_type(BrandAIProductResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_ai_product(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.ai_product( - url="https://example.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandAIProductResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_ai_product(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.ai_product( - url="https://example.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandAIProductResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_ai_products_overload_1(self, client: ContextDev) -> None: - brand = client.brand.ai_products( - domain="domain", - ) - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_ai_products_with_all_params_overload_1(self, client: ContextDev) -> None: - brand = client.brand.ai_products( - domain="domain", - max_products=1, - timeout_ms=1000, - ) - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_ai_products_overload_1(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.ai_products( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_ai_products_overload_1(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.ai_products( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_ai_products_overload_2(self, client: ContextDev) -> None: - brand = client.brand.ai_products( - direct_url="https://example.com", - ) - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_ai_products_with_all_params_overload_2(self, client: ContextDev) -> None: - brand = client.brand.ai_products( - direct_url="https://example.com", - max_products=1, - timeout_ms=1000, - ) - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_ai_products_overload_2(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.ai_products( - direct_url="https://example.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_ai_products_overload_2(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.ai_products( - direct_url="https://example.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_ai_query(self, client: ContextDev) -> None: - brand = client.brand.ai_query( - data_to_extract=[ - { - "datapoint_description": "datapoint_description", - "datapoint_example": "datapoint_example", - "datapoint_name": "datapoint_name", - "datapoint_type": "text", - } - ], - domain="domain", - ) - assert_matches_type(BrandAIQueryResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_ai_query_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.ai_query( - data_to_extract=[ - { - "datapoint_description": "datapoint_description", - "datapoint_example": "datapoint_example", - "datapoint_name": "datapoint_name", - "datapoint_type": "text", - "datapoint_list_type": "string", - "datapoint_object_schema": { - "testimonial_text": "string", - "testimonial_author": "string", - }, - } - ], - domain="domain", - specific_pages={ - "about_us": True, - "blog": True, - "careers": True, - "contact_us": True, - "faq": True, - "home_page": True, - "pricing": True, - "privacy_policy": True, - "terms_and_conditions": True, - }, - timeout_ms=1000, - ) - assert_matches_type(BrandAIQueryResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_ai_query(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.ai_query( - data_to_extract=[ - { - "datapoint_description": "datapoint_description", - "datapoint_example": "datapoint_example", - "datapoint_name": "datapoint_name", - "datapoint_type": "text", - } - ], - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandAIQueryResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_ai_query(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.ai_query( - data_to_extract=[ - { - "datapoint_description": "datapoint_description", - "datapoint_example": "datapoint_example", - "datapoint_name": "datapoint_name", - "datapoint_type": "text", - } - ], - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandAIQueryResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_fonts(self, client: ContextDev) -> None: - brand = client.brand.fonts( - domain="domain", - ) - assert_matches_type(BrandFontsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_fonts_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.fonts( - domain="domain", - timeout_ms=1000, - ) - assert_matches_type(BrandFontsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_fonts(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.fonts( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandFontsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_fonts(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.fonts( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandFontsResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_identify_from_transaction(self, client: ContextDev) -> None: @@ -398,92 +120,6 @@ def test_streaming_response_identify_from_transaction(self, client: ContextDev) assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_prefetch(self, client: ContextDev) -> None: - brand = client.brand.prefetch( - domain="domain", - ) - assert_matches_type(BrandPrefetchResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_prefetch_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.prefetch( - domain="domain", - timeout_ms=1000, - ) - assert_matches_type(BrandPrefetchResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_prefetch(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.prefetch( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandPrefetchResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_prefetch(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.prefetch( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandPrefetchResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_prefetch_by_email(self, client: ContextDev) -> None: - brand = client.brand.prefetch_by_email( - email="dev@stainless.com", - ) - assert_matches_type(BrandPrefetchByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_prefetch_by_email_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.prefetch_by_email( - email="dev@stainless.com", - timeout_ms=1000, - ) - assert_matches_type(BrandPrefetchByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_prefetch_by_email(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.prefetch_by_email( - email="dev@stainless.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandPrefetchByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_prefetch_by_email(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.prefetch_by_email( - email="dev@stainless.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandPrefetchByEmailResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_retrieve_by_email(self, client: ContextDev) -> None: @@ -506,994 +142,41 @@ def test_method_retrieve_by_email_with_all_params(self, client: ContextDev) -> N @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_raw_response_retrieve_by_email(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.retrieve_by_email( - email="dev@stainless.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve_by_email(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.retrieve_by_email( - email="dev@stainless.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_by_isin(self, client: ContextDev) -> None: - brand = client.brand.retrieve_by_isin( - isin="SE60513A9993", - ) - assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_by_isin_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.retrieve_by_isin( - isin="SE60513A9993", - force_language="albanian", - max_speed=True, - timeout_ms=1000, - ) - assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve_by_isin(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.retrieve_by_isin( - isin="SE60513A9993", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve_by_isin(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.retrieve_by_isin( - isin="SE60513A9993", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_by_name(self, client: ContextDev) -> None: - brand = client.brand.retrieve_by_name( - name="xxx", - ) - assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_by_name_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.retrieve_by_name( - name="xxx", - country_gl="ad", - force_language="albanian", - max_speed=True, - timeout_ms=1000, - ) - assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve_by_name(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.retrieve_by_name( - name="xxx", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve_by_name(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.retrieve_by_name( - name="xxx", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_by_ticker(self, client: ContextDev) -> None: - brand = client.brand.retrieve_by_ticker( - ticker="ticker", - ) - assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_by_ticker_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.retrieve_by_ticker( - ticker="ticker", - force_language="albanian", - max_speed=True, - ticker_exchange="AMEX", - timeout_ms=1000, - ) - assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve_by_ticker(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.retrieve_by_ticker( - ticker="ticker", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve_by_ticker(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.retrieve_by_ticker( - ticker="ticker", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_naics(self, client: ContextDev) -> None: - brand = client.brand.retrieve_naics( - input="input", - ) - assert_matches_type(BrandRetrieveNaicsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_naics_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.retrieve_naics( - input="input", - max_results=1, - min_results=1, - timeout_ms=1000, - ) - assert_matches_type(BrandRetrieveNaicsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve_naics(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.retrieve_naics( - input="input", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandRetrieveNaicsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve_naics(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.retrieve_naics( - input="input", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandRetrieveNaicsResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_simplified(self, client: ContextDev) -> None: - brand = client.brand.retrieve_simplified( - domain="domain", - ) - assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_simplified_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.retrieve_simplified( - domain="domain", - timeout_ms=1000, - ) - assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve_simplified(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.retrieve_simplified( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve_simplified(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.retrieve_simplified( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_screenshot(self, client: ContextDev) -> None: - brand = client.brand.screenshot( - domain="domain", - ) - assert_matches_type(BrandScreenshotResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_screenshot_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.screenshot( - domain="domain", - full_screenshot="true", - page="login", - prioritize="speed", - ) - assert_matches_type(BrandScreenshotResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_screenshot(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.screenshot( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandScreenshotResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_screenshot(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.screenshot( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandScreenshotResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_styleguide(self, client: ContextDev) -> None: - brand = client.brand.styleguide() - assert_matches_type(BrandStyleguideResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_styleguide_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.styleguide( - direct_url="https://example.com", - domain="domain", - prioritize="speed", - timeout_ms=1000, - ) - assert_matches_type(BrandStyleguideResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_styleguide(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.styleguide() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandStyleguideResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_styleguide(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.styleguide() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandStyleguideResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_web_scrape_html(self, client: ContextDev) -> None: - brand = client.brand.web_scrape_html( - url="https://example.com", - ) - assert_matches_type(BrandWebScrapeHTMLResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_web_scrape_html(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.web_scrape_html( - url="https://example.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandWebScrapeHTMLResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_web_scrape_html(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.web_scrape_html( - url="https://example.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandWebScrapeHTMLResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_web_scrape_images(self, client: ContextDev) -> None: - brand = client.brand.web_scrape_images( - url="https://example.com", - ) - assert_matches_type(BrandWebScrapeImagesResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_web_scrape_images(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.web_scrape_images( - url="https://example.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandWebScrapeImagesResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_web_scrape_images(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.web_scrape_images( - url="https://example.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandWebScrapeImagesResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_web_scrape_md(self, client: ContextDev) -> None: - brand = client.brand.web_scrape_md( - url="https://example.com", - ) - assert_matches_type(BrandWebScrapeMdResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_web_scrape_md_with_all_params(self, client: ContextDev) -> None: - brand = client.brand.web_scrape_md( - url="https://example.com", - include_images=True, - include_links=True, - shorten_base64_images=True, - ) - assert_matches_type(BrandWebScrapeMdResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_web_scrape_md(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.web_scrape_md( - url="https://example.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandWebScrapeMdResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_web_scrape_md(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.web_scrape_md( - url="https://example.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandWebScrapeMdResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_web_scrape_sitemap(self, client: ContextDev) -> None: - brand = client.brand.web_scrape_sitemap( - domain="domain", - ) - assert_matches_type(BrandWebScrapeSitemapResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_web_scrape_sitemap(self, client: ContextDev) -> None: - response = client.brand.with_raw_response.web_scrape_sitemap( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = response.parse() - assert_matches_type(BrandWebScrapeSitemapResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_web_scrape_sitemap(self, client: ContextDev) -> None: - with client.brand.with_streaming_response.web_scrape_sitemap( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = response.parse() - assert_matches_type(BrandWebScrapeSitemapResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - -class TestAsyncBrand: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve( - domain="domain", - ) - assert_matches_type(BrandRetrieveResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve( - domain="domain", - force_language="albanian", - max_speed=True, - timeout_ms=1000, - ) - assert_matches_type(BrandRetrieveResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.retrieve( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandRetrieveResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.retrieve( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandRetrieveResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_ai_product(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.ai_product( - url="https://example.com", - ) - assert_matches_type(BrandAIProductResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_ai_product_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.ai_product( - url="https://example.com", - timeout_ms=1000, - ) - assert_matches_type(BrandAIProductResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_ai_product(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.ai_product( - url="https://example.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandAIProductResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_ai_product(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.ai_product( - url="https://example.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandAIProductResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_ai_products_overload_1(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.ai_products( - domain="domain", - ) - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_ai_products_with_all_params_overload_1(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.ai_products( - domain="domain", - max_products=1, - timeout_ms=1000, - ) - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_ai_products_overload_1(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.ai_products( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_ai_products_overload_1(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.ai_products( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_ai_products_overload_2(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.ai_products( - direct_url="https://example.com", - ) - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_ai_products_with_all_params_overload_2(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.ai_products( - direct_url="https://example.com", - max_products=1, - timeout_ms=1000, - ) - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_ai_products_overload_2(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.ai_products( - direct_url="https://example.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_ai_products_overload_2(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.ai_products( - direct_url="https://example.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandAIProductsResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_ai_query(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.ai_query( - data_to_extract=[ - { - "datapoint_description": "datapoint_description", - "datapoint_example": "datapoint_example", - "datapoint_name": "datapoint_name", - "datapoint_type": "text", - } - ], - domain="domain", - ) - assert_matches_type(BrandAIQueryResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_ai_query_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.ai_query( - data_to_extract=[ - { - "datapoint_description": "datapoint_description", - "datapoint_example": "datapoint_example", - "datapoint_name": "datapoint_name", - "datapoint_type": "text", - "datapoint_list_type": "string", - "datapoint_object_schema": { - "testimonial_text": "string", - "testimonial_author": "string", - }, - } - ], - domain="domain", - specific_pages={ - "about_us": True, - "blog": True, - "careers": True, - "contact_us": True, - "faq": True, - "home_page": True, - "pricing": True, - "privacy_policy": True, - "terms_and_conditions": True, - }, - timeout_ms=1000, - ) - assert_matches_type(BrandAIQueryResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_ai_query(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.ai_query( - data_to_extract=[ - { - "datapoint_description": "datapoint_description", - "datapoint_example": "datapoint_example", - "datapoint_name": "datapoint_name", - "datapoint_type": "text", - } - ], - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandAIQueryResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_ai_query(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.ai_query( - data_to_extract=[ - { - "datapoint_description": "datapoint_description", - "datapoint_example": "datapoint_example", - "datapoint_name": "datapoint_name", - "datapoint_type": "text", - } - ], - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandAIQueryResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_fonts(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.fonts( - domain="domain", - ) - assert_matches_type(BrandFontsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_fonts_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.fonts( - domain="domain", - timeout_ms=1000, - ) - assert_matches_type(BrandFontsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_fonts(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.fonts( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandFontsResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_fonts(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.fonts( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandFontsResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_identify_from_transaction(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.identify_from_transaction( - transaction_info="transaction_info", - ) - assert_matches_type(BrandIdentifyFromTransactionResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_identify_from_transaction_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.identify_from_transaction( - transaction_info="transaction_info", - city="city", - country_gl="ad", - force_language="albanian", - high_confidence_only=True, - max_speed=True, - mcc="mcc", - phone=0, - timeout_ms=1000, - ) - assert_matches_type(BrandIdentifyFromTransactionResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_identify_from_transaction(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.identify_from_transaction( - transaction_info="transaction_info", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandIdentifyFromTransactionResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_identify_from_transaction(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.identify_from_transaction( - transaction_info="transaction_info", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandIdentifyFromTransactionResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_prefetch(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.prefetch( - domain="domain", - ) - assert_matches_type(BrandPrefetchResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_prefetch_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.prefetch( - domain="domain", - timeout_ms=1000, - ) - assert_matches_type(BrandPrefetchResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_prefetch(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.prefetch( - domain="domain", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandPrefetchResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_prefetch(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.prefetch( - domain="domain", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandPrefetchResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_prefetch_by_email(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.prefetch_by_email( - email="dev@stainless.com", - ) - assert_matches_type(BrandPrefetchByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_prefetch_by_email_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.prefetch_by_email( - email="dev@stainless.com", - timeout_ms=1000, - ) - assert_matches_type(BrandPrefetchByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_prefetch_by_email(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.prefetch_by_email( - email="dev@stainless.com", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandPrefetchByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_prefetch_by_email(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.prefetch_by_email( - email="dev@stainless.com", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - brand = await response.parse() - assert_matches_type(BrandPrefetchByEmailResponse, brand, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve_by_email(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_by_email( - email="dev@stainless.com", - ) - assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve_by_email_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_by_email( - email="dev@stainless.com", - force_language="albanian", - max_speed=True, - timeout_ms=1000, - ) - assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_retrieve_by_email(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.retrieve_by_email( + response = client.brand.with_raw_response.retrieve_by_email( email="dev@stainless.com", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() + brand = response.parse() assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_retrieve_by_email(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.retrieve_by_email( + def test_streaming_response_retrieve_by_email(self, client: ContextDev) -> None: + with client.brand.with_streaming_response.retrieve_by_email( email="dev@stainless.com", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() + brand = response.parse() assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_by_isin(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_by_isin( + def test_method_retrieve_by_isin(self, client: ContextDev) -> None: + brand = client.brand.retrieve_by_isin( isin="SE60513A9993", ) assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_by_isin_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_by_isin( + def test_method_retrieve_by_isin_with_all_params(self, client: ContextDev) -> None: + brand = client.brand.retrieve_by_isin( isin="SE60513A9993", force_language="albanian", max_speed=True, @@ -1503,42 +186,42 @@ async def test_method_retrieve_by_isin_with_all_params(self, async_client: Async @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_retrieve_by_isin(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.retrieve_by_isin( + def test_raw_response_retrieve_by_isin(self, client: ContextDev) -> None: + response = client.brand.with_raw_response.retrieve_by_isin( isin="SE60513A9993", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() + brand = response.parse() assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_retrieve_by_isin(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.retrieve_by_isin( + def test_streaming_response_retrieve_by_isin(self, client: ContextDev) -> None: + with client.brand.with_streaming_response.retrieve_by_isin( isin="SE60513A9993", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() + brand = response.parse() assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_by_name(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_by_name( + def test_method_retrieve_by_name(self, client: ContextDev) -> None: + brand = client.brand.retrieve_by_name( name="xxx", ) assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_by_name_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_by_name( + def test_method_retrieve_by_name_with_all_params(self, client: ContextDev) -> None: + brand = client.brand.retrieve_by_name( name="xxx", country_gl="ad", force_language="albanian", @@ -1549,42 +232,42 @@ async def test_method_retrieve_by_name_with_all_params(self, async_client: Async @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_retrieve_by_name(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.retrieve_by_name( + def test_raw_response_retrieve_by_name(self, client: ContextDev) -> None: + response = client.brand.with_raw_response.retrieve_by_name( name="xxx", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() + brand = response.parse() assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_retrieve_by_name(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.retrieve_by_name( + def test_streaming_response_retrieve_by_name(self, client: ContextDev) -> None: + with client.brand.with_streaming_response.retrieve_by_name( name="xxx", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() + brand = response.parse() assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_by_ticker(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_by_ticker( + def test_method_retrieve_by_ticker(self, client: ContextDev) -> None: + brand = client.brand.retrieve_by_ticker( ticker="ticker", ) assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_by_ticker_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_by_ticker( + def test_method_retrieve_by_ticker_with_all_params(self, client: ContextDev) -> None: + brand = client.brand.retrieve_by_ticker( ticker="ticker", force_language="albanian", max_speed=True, @@ -1595,345 +278,395 @@ async def test_method_retrieve_by_ticker_with_all_params(self, async_client: Asy @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_retrieve_by_ticker(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.retrieve_by_ticker( + def test_raw_response_retrieve_by_ticker(self, client: ContextDev) -> None: + response = client.brand.with_raw_response.retrieve_by_ticker( ticker="ticker", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() + brand = response.parse() assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_retrieve_by_ticker(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.retrieve_by_ticker( + def test_streaming_response_retrieve_by_ticker(self, client: ContextDev) -> None: + with client.brand.with_streaming_response.retrieve_by_ticker( ticker="ticker", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() + brand = response.parse() assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_naics(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_naics( - input="input", + def test_method_retrieve_simplified(self, client: ContextDev) -> None: + brand = client.brand.retrieve_simplified( + domain="domain", ) - assert_matches_type(BrandRetrieveNaicsResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_naics_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_naics( - input="input", - max_results=1, - min_results=1, + def test_method_retrieve_simplified_with_all_params(self, client: ContextDev) -> None: + brand = client.brand.retrieve_simplified( + domain="domain", timeout_ms=1000, ) - assert_matches_type(BrandRetrieveNaicsResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_retrieve_naics(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.retrieve_naics( - input="input", + def test_raw_response_retrieve_simplified(self, client: ContextDev) -> None: + response = client.brand.with_raw_response.retrieve_simplified( + domain="domain", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandRetrieveNaicsResponse, brand, path=["response"]) + brand = response.parse() + assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_retrieve_naics(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.retrieve_naics( - input="input", + def test_streaming_response_retrieve_simplified(self, client: ContextDev) -> None: + with client.brand.with_streaming_response.retrieve_simplified( + domain="domain", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - brand = await response.parse() - assert_matches_type(BrandRetrieveNaicsResponse, brand, path=["response"]) + brand = response.parse() + assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True + +class TestAsyncBrand: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_simplified(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_simplified( + async def test_method_retrieve(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve( domain="domain", ) - assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve_simplified_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.retrieve_simplified( + async def test_method_retrieve_with_all_params(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve( domain="domain", + force_language="albanian", + max_speed=True, timeout_ms=1000, ) - assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_retrieve_simplified(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.retrieve_simplified( + async def test_raw_response_retrieve(self, async_client: AsyncContextDev) -> None: + response = await async_client.brand.with_raw_response.retrieve( domain="domain", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_retrieve_simplified(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.retrieve_simplified( + async def test_streaming_response_retrieve(self, async_client: AsyncContextDev) -> None: + async with async_client.brand.with_streaming_response.retrieve( domain="domain", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_screenshot(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.screenshot( - domain="domain", + async def test_method_identify_from_transaction(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.identify_from_transaction( + transaction_info="transaction_info", ) - assert_matches_type(BrandScreenshotResponse, brand, path=["response"]) + assert_matches_type(BrandIdentifyFromTransactionResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_screenshot_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.screenshot( - domain="domain", - full_screenshot="true", - page="login", - prioritize="speed", + async def test_method_identify_from_transaction_with_all_params(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.identify_from_transaction( + transaction_info="transaction_info", + city="city", + country_gl="ad", + force_language="albanian", + high_confidence_only=True, + max_speed=True, + mcc="mcc", + phone=0, + timeout_ms=1000, ) - assert_matches_type(BrandScreenshotResponse, brand, path=["response"]) + assert_matches_type(BrandIdentifyFromTransactionResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_screenshot(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.screenshot( - domain="domain", + async def test_raw_response_identify_from_transaction(self, async_client: AsyncContextDev) -> None: + response = await async_client.brand.with_raw_response.identify_from_transaction( + transaction_info="transaction_info", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandScreenshotResponse, brand, path=["response"]) + assert_matches_type(BrandIdentifyFromTransactionResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_screenshot(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.screenshot( - domain="domain", + async def test_streaming_response_identify_from_transaction(self, async_client: AsyncContextDev) -> None: + async with async_client.brand.with_streaming_response.identify_from_transaction( + transaction_info="transaction_info", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandScreenshotResponse, brand, path=["response"]) + assert_matches_type(BrandIdentifyFromTransactionResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_styleguide(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.styleguide() - assert_matches_type(BrandStyleguideResponse, brand, path=["response"]) + async def test_method_retrieve_by_email(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_by_email( + email="dev@stainless.com", + ) + assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_styleguide_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.styleguide( - direct_url="https://example.com", - domain="domain", - prioritize="speed", + async def test_method_retrieve_by_email_with_all_params(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_by_email( + email="dev@stainless.com", + force_language="albanian", + max_speed=True, timeout_ms=1000, ) - assert_matches_type(BrandStyleguideResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_styleguide(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.styleguide() + async def test_raw_response_retrieve_by_email(self, async_client: AsyncContextDev) -> None: + response = await async_client.brand.with_raw_response.retrieve_by_email( + email="dev@stainless.com", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandStyleguideResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_styleguide(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.styleguide() as response: + async def test_streaming_response_retrieve_by_email(self, async_client: AsyncContextDev) -> None: + async with async_client.brand.with_streaming_response.retrieve_by_email( + email="dev@stainless.com", + ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandStyleguideResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByEmailResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_web_scrape_html(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.web_scrape_html( - url="https://example.com", + async def test_method_retrieve_by_isin(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_by_isin( + isin="SE60513A9993", + ) + assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_by_isin_with_all_params(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_by_isin( + isin="SE60513A9993", + force_language="albanian", + max_speed=True, + timeout_ms=1000, ) - assert_matches_type(BrandWebScrapeHTMLResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_web_scrape_html(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.web_scrape_html( - url="https://example.com", + async def test_raw_response_retrieve_by_isin(self, async_client: AsyncContextDev) -> None: + response = await async_client.brand.with_raw_response.retrieve_by_isin( + isin="SE60513A9993", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandWebScrapeHTMLResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_web_scrape_html(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.web_scrape_html( - url="https://example.com", + async def test_streaming_response_retrieve_by_isin(self, async_client: AsyncContextDev) -> None: + async with async_client.brand.with_streaming_response.retrieve_by_isin( + isin="SE60513A9993", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandWebScrapeHTMLResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByIsinResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_web_scrape_images(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.web_scrape_images( - url="https://example.com", + async def test_method_retrieve_by_name(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_by_name( + name="xxx", + ) + assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_by_name_with_all_params(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_by_name( + name="xxx", + country_gl="ad", + force_language="albanian", + max_speed=True, + timeout_ms=1000, ) - assert_matches_type(BrandWebScrapeImagesResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_web_scrape_images(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.web_scrape_images( - url="https://example.com", + async def test_raw_response_retrieve_by_name(self, async_client: AsyncContextDev) -> None: + response = await async_client.brand.with_raw_response.retrieve_by_name( + name="xxx", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandWebScrapeImagesResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_web_scrape_images(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.web_scrape_images( - url="https://example.com", + async def test_streaming_response_retrieve_by_name(self, async_client: AsyncContextDev) -> None: + async with async_client.brand.with_streaming_response.retrieve_by_name( + name="xxx", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandWebScrapeImagesResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByNameResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_web_scrape_md(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.web_scrape_md( - url="https://example.com", + async def test_method_retrieve_by_ticker(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_by_ticker( + ticker="ticker", ) - assert_matches_type(BrandWebScrapeMdResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_web_scrape_md_with_all_params(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.web_scrape_md( - url="https://example.com", - include_images=True, - include_links=True, - shorten_base64_images=True, + async def test_method_retrieve_by_ticker_with_all_params(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_by_ticker( + ticker="ticker", + force_language="albanian", + max_speed=True, + ticker_exchange="AMEX", + timeout_ms=1000, ) - assert_matches_type(BrandWebScrapeMdResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_web_scrape_md(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.web_scrape_md( - url="https://example.com", + async def test_raw_response_retrieve_by_ticker(self, async_client: AsyncContextDev) -> None: + response = await async_client.brand.with_raw_response.retrieve_by_ticker( + ticker="ticker", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandWebScrapeMdResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_web_scrape_md(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.web_scrape_md( - url="https://example.com", + async def test_streaming_response_retrieve_by_ticker(self, async_client: AsyncContextDev) -> None: + async with async_client.brand.with_streaming_response.retrieve_by_ticker( + ticker="ticker", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandWebScrapeMdResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveByTickerResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_web_scrape_sitemap(self, async_client: AsyncContextDev) -> None: - brand = await async_client.brand.web_scrape_sitemap( + async def test_method_retrieve_simplified(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_simplified( + domain="domain", + ) + assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_simplified_with_all_params(self, async_client: AsyncContextDev) -> None: + brand = await async_client.brand.retrieve_simplified( domain="domain", + timeout_ms=1000, ) - assert_matches_type(BrandWebScrapeSitemapResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_web_scrape_sitemap(self, async_client: AsyncContextDev) -> None: - response = await async_client.brand.with_raw_response.web_scrape_sitemap( + async def test_raw_response_retrieve_simplified(self, async_client: AsyncContextDev) -> None: + response = await async_client.brand.with_raw_response.retrieve_simplified( domain="domain", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandWebScrapeSitemapResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_web_scrape_sitemap(self, async_client: AsyncContextDev) -> None: - async with async_client.brand.with_streaming_response.web_scrape_sitemap( + async def test_streaming_response_retrieve_simplified(self, async_client: AsyncContextDev) -> None: + async with async_client.brand.with_streaming_response.retrieve_simplified( domain="domain", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" brand = await response.parse() - assert_matches_type(BrandWebScrapeSitemapResponse, brand, path=["response"]) + assert_matches_type(BrandRetrieveSimplifiedResponse, brand, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_industry.py b/tests/api_resources/test_industry.py new file mode 100644 index 0000000..543c358 --- /dev/null +++ b/tests/api_resources/test_industry.py @@ -0,0 +1,114 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from context.dev import ContextDev, AsyncContextDev +from tests.utils import assert_matches_type +from context.dev.types import IndustryRetrieveNaicsResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestIndustry: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_naics(self, client: ContextDev) -> None: + industry = client.industry.retrieve_naics( + input="input", + ) + assert_matches_type(IndustryRetrieveNaicsResponse, industry, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_naics_with_all_params(self, client: ContextDev) -> None: + industry = client.industry.retrieve_naics( + input="input", + max_results=1, + min_results=1, + timeout_ms=1000, + ) + assert_matches_type(IndustryRetrieveNaicsResponse, industry, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve_naics(self, client: ContextDev) -> None: + response = client.industry.with_raw_response.retrieve_naics( + input="input", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + industry = response.parse() + assert_matches_type(IndustryRetrieveNaicsResponse, industry, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve_naics(self, client: ContextDev) -> None: + with client.industry.with_streaming_response.retrieve_naics( + input="input", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + industry = response.parse() + assert_matches_type(IndustryRetrieveNaicsResponse, industry, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncIndustry: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_naics(self, async_client: AsyncContextDev) -> None: + industry = await async_client.industry.retrieve_naics( + input="input", + ) + assert_matches_type(IndustryRetrieveNaicsResponse, industry, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_naics_with_all_params(self, async_client: AsyncContextDev) -> None: + industry = await async_client.industry.retrieve_naics( + input="input", + max_results=1, + min_results=1, + timeout_ms=1000, + ) + assert_matches_type(IndustryRetrieveNaicsResponse, industry, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve_naics(self, async_client: AsyncContextDev) -> None: + response = await async_client.industry.with_raw_response.retrieve_naics( + input="input", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + industry = await response.parse() + assert_matches_type(IndustryRetrieveNaicsResponse, industry, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve_naics(self, async_client: AsyncContextDev) -> None: + async with async_client.industry.with_streaming_response.retrieve_naics( + input="input", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + industry = await response.parse() + assert_matches_type(IndustryRetrieveNaicsResponse, industry, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_style.py b/tests/api_resources/test_style.py new file mode 100644 index 0000000..d1e8bc6 --- /dev/null +++ b/tests/api_resources/test_style.py @@ -0,0 +1,191 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from context.dev import ContextDev, AsyncContextDev +from tests.utils import assert_matches_type +from context.dev.types import ( + StyleExtractFontsResponse, + StyleExtractStyleguideResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestStyle: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_fonts(self, client: ContextDev) -> None: + style = client.style.extract_fonts( + domain="domain", + ) + assert_matches_type(StyleExtractFontsResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_fonts_with_all_params(self, client: ContextDev) -> None: + style = client.style.extract_fonts( + domain="domain", + timeout_ms=1000, + ) + assert_matches_type(StyleExtractFontsResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_extract_fonts(self, client: ContextDev) -> None: + response = client.style.with_raw_response.extract_fonts( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + style = response.parse() + assert_matches_type(StyleExtractFontsResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_extract_fonts(self, client: ContextDev) -> None: + with client.style.with_streaming_response.extract_fonts( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + style = response.parse() + assert_matches_type(StyleExtractFontsResponse, style, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_styleguide(self, client: ContextDev) -> None: + style = client.style.extract_styleguide() + assert_matches_type(StyleExtractStyleguideResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_extract_styleguide_with_all_params(self, client: ContextDev) -> None: + style = client.style.extract_styleguide( + direct_url="https://example.com", + domain="domain", + prioritize="speed", + timeout_ms=1000, + ) + assert_matches_type(StyleExtractStyleguideResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_extract_styleguide(self, client: ContextDev) -> None: + response = client.style.with_raw_response.extract_styleguide() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + style = response.parse() + assert_matches_type(StyleExtractStyleguideResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_extract_styleguide(self, client: ContextDev) -> None: + with client.style.with_streaming_response.extract_styleguide() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + style = response.parse() + assert_matches_type(StyleExtractStyleguideResponse, style, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncStyle: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_fonts(self, async_client: AsyncContextDev) -> None: + style = await async_client.style.extract_fonts( + domain="domain", + ) + assert_matches_type(StyleExtractFontsResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_fonts_with_all_params(self, async_client: AsyncContextDev) -> None: + style = await async_client.style.extract_fonts( + domain="domain", + timeout_ms=1000, + ) + assert_matches_type(StyleExtractFontsResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_extract_fonts(self, async_client: AsyncContextDev) -> None: + response = await async_client.style.with_raw_response.extract_fonts( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + style = await response.parse() + assert_matches_type(StyleExtractFontsResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_extract_fonts(self, async_client: AsyncContextDev) -> None: + async with async_client.style.with_streaming_response.extract_fonts( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + style = await response.parse() + assert_matches_type(StyleExtractFontsResponse, style, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_styleguide(self, async_client: AsyncContextDev) -> None: + style = await async_client.style.extract_styleguide() + assert_matches_type(StyleExtractStyleguideResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_extract_styleguide_with_all_params(self, async_client: AsyncContextDev) -> None: + style = await async_client.style.extract_styleguide( + direct_url="https://example.com", + domain="domain", + prioritize="speed", + timeout_ms=1000, + ) + assert_matches_type(StyleExtractStyleguideResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_extract_styleguide(self, async_client: AsyncContextDev) -> None: + response = await async_client.style.with_raw_response.extract_styleguide() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + style = await response.parse() + assert_matches_type(StyleExtractStyleguideResponse, style, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_extract_styleguide(self, async_client: AsyncContextDev) -> None: + async with async_client.style.with_streaming_response.extract_styleguide() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + style = await response.parse() + assert_matches_type(StyleExtractStyleguideResponse, style, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_utility.py b/tests/api_resources/test_utility.py new file mode 100644 index 0000000..112de67 --- /dev/null +++ b/tests/api_resources/test_utility.py @@ -0,0 +1,199 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from context.dev import ContextDev, AsyncContextDev +from tests.utils import assert_matches_type +from context.dev.types import ( + UtilityPrefetchResponse, + UtilityPrefetchByEmailResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestUtility: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_prefetch(self, client: ContextDev) -> None: + utility = client.utility.prefetch( + domain="domain", + ) + assert_matches_type(UtilityPrefetchResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_prefetch_with_all_params(self, client: ContextDev) -> None: + utility = client.utility.prefetch( + domain="domain", + timeout_ms=1000, + ) + assert_matches_type(UtilityPrefetchResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_prefetch(self, client: ContextDev) -> None: + response = client.utility.with_raw_response.prefetch( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + utility = response.parse() + assert_matches_type(UtilityPrefetchResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_prefetch(self, client: ContextDev) -> None: + with client.utility.with_streaming_response.prefetch( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + utility = response.parse() + assert_matches_type(UtilityPrefetchResponse, utility, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_prefetch_by_email(self, client: ContextDev) -> None: + utility = client.utility.prefetch_by_email( + email="dev@stainless.com", + ) + assert_matches_type(UtilityPrefetchByEmailResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_prefetch_by_email_with_all_params(self, client: ContextDev) -> None: + utility = client.utility.prefetch_by_email( + email="dev@stainless.com", + timeout_ms=1000, + ) + assert_matches_type(UtilityPrefetchByEmailResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_prefetch_by_email(self, client: ContextDev) -> None: + response = client.utility.with_raw_response.prefetch_by_email( + email="dev@stainless.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + utility = response.parse() + assert_matches_type(UtilityPrefetchByEmailResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_prefetch_by_email(self, client: ContextDev) -> None: + with client.utility.with_streaming_response.prefetch_by_email( + email="dev@stainless.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + utility = response.parse() + assert_matches_type(UtilityPrefetchByEmailResponse, utility, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncUtility: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_prefetch(self, async_client: AsyncContextDev) -> None: + utility = await async_client.utility.prefetch( + domain="domain", + ) + assert_matches_type(UtilityPrefetchResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_prefetch_with_all_params(self, async_client: AsyncContextDev) -> None: + utility = await async_client.utility.prefetch( + domain="domain", + timeout_ms=1000, + ) + assert_matches_type(UtilityPrefetchResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_prefetch(self, async_client: AsyncContextDev) -> None: + response = await async_client.utility.with_raw_response.prefetch( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + utility = await response.parse() + assert_matches_type(UtilityPrefetchResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_prefetch(self, async_client: AsyncContextDev) -> None: + async with async_client.utility.with_streaming_response.prefetch( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + utility = await response.parse() + assert_matches_type(UtilityPrefetchResponse, utility, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_prefetch_by_email(self, async_client: AsyncContextDev) -> None: + utility = await async_client.utility.prefetch_by_email( + email="dev@stainless.com", + ) + assert_matches_type(UtilityPrefetchByEmailResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_prefetch_by_email_with_all_params(self, async_client: AsyncContextDev) -> None: + utility = await async_client.utility.prefetch_by_email( + email="dev@stainless.com", + timeout_ms=1000, + ) + assert_matches_type(UtilityPrefetchByEmailResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_prefetch_by_email(self, async_client: AsyncContextDev) -> None: + response = await async_client.utility.with_raw_response.prefetch_by_email( + email="dev@stainless.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + utility = await response.parse() + assert_matches_type(UtilityPrefetchByEmailResponse, utility, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_prefetch_by_email(self, async_client: AsyncContextDev) -> None: + async with async_client.utility.with_streaming_response.prefetch_by_email( + email="dev@stainless.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + utility = await response.parse() + assert_matches_type(UtilityPrefetchByEmailResponse, utility, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_web.py b/tests/api_resources/test_web.py new file mode 100644 index 0000000..c837e7d --- /dev/null +++ b/tests/api_resources/test_web.py @@ -0,0 +1,414 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from context.dev import ContextDev, AsyncContextDev +from tests.utils import assert_matches_type +from context.dev.types import ( + WebScreenshotResponse, + WebWebScrapeMdResponse, + WebWebScrapeHTMLResponse, + WebWebScrapeImagesResponse, + WebWebScrapeSitemapResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestWeb: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_screenshot(self, client: ContextDev) -> None: + web = client.web.screenshot( + domain="domain", + ) + assert_matches_type(WebScreenshotResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_screenshot_with_all_params(self, client: ContextDev) -> None: + web = client.web.screenshot( + domain="domain", + full_screenshot="true", + page="login", + prioritize="speed", + ) + assert_matches_type(WebScreenshotResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_screenshot(self, client: ContextDev) -> None: + response = client.web.with_raw_response.screenshot( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = response.parse() + assert_matches_type(WebScreenshotResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_screenshot(self, client: ContextDev) -> None: + with client.web.with_streaming_response.screenshot( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = response.parse() + assert_matches_type(WebScreenshotResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_web_scrape_html(self, client: ContextDev) -> None: + web = client.web.web_scrape_html( + url="https://example.com", + ) + assert_matches_type(WebWebScrapeHTMLResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_web_scrape_html(self, client: ContextDev) -> None: + response = client.web.with_raw_response.web_scrape_html( + url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = response.parse() + assert_matches_type(WebWebScrapeHTMLResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_web_scrape_html(self, client: ContextDev) -> None: + with client.web.with_streaming_response.web_scrape_html( + url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = response.parse() + assert_matches_type(WebWebScrapeHTMLResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_web_scrape_images(self, client: ContextDev) -> None: + web = client.web.web_scrape_images( + url="https://example.com", + ) + assert_matches_type(WebWebScrapeImagesResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_web_scrape_images(self, client: ContextDev) -> None: + response = client.web.with_raw_response.web_scrape_images( + url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = response.parse() + assert_matches_type(WebWebScrapeImagesResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_web_scrape_images(self, client: ContextDev) -> None: + with client.web.with_streaming_response.web_scrape_images( + url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = response.parse() + assert_matches_type(WebWebScrapeImagesResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_web_scrape_md(self, client: ContextDev) -> None: + web = client.web.web_scrape_md( + url="https://example.com", + ) + assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_web_scrape_md_with_all_params(self, client: ContextDev) -> None: + web = client.web.web_scrape_md( + url="https://example.com", + include_images=True, + include_links=True, + shorten_base64_images=True, + ) + assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_web_scrape_md(self, client: ContextDev) -> None: + response = client.web.with_raw_response.web_scrape_md( + url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = response.parse() + assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_web_scrape_md(self, client: ContextDev) -> None: + with client.web.with_streaming_response.web_scrape_md( + url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = response.parse() + assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_web_scrape_sitemap(self, client: ContextDev) -> None: + web = client.web.web_scrape_sitemap( + domain="domain", + ) + assert_matches_type(WebWebScrapeSitemapResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_web_scrape_sitemap(self, client: ContextDev) -> None: + response = client.web.with_raw_response.web_scrape_sitemap( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = response.parse() + assert_matches_type(WebWebScrapeSitemapResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_web_scrape_sitemap(self, client: ContextDev) -> None: + with client.web.with_streaming_response.web_scrape_sitemap( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = response.parse() + assert_matches_type(WebWebScrapeSitemapResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncWeb: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_screenshot(self, async_client: AsyncContextDev) -> None: + web = await async_client.web.screenshot( + domain="domain", + ) + assert_matches_type(WebScreenshotResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_screenshot_with_all_params(self, async_client: AsyncContextDev) -> None: + web = await async_client.web.screenshot( + domain="domain", + full_screenshot="true", + page="login", + prioritize="speed", + ) + assert_matches_type(WebScreenshotResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_screenshot(self, async_client: AsyncContextDev) -> None: + response = await async_client.web.with_raw_response.screenshot( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = await response.parse() + assert_matches_type(WebScreenshotResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_screenshot(self, async_client: AsyncContextDev) -> None: + async with async_client.web.with_streaming_response.screenshot( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = await response.parse() + assert_matches_type(WebScreenshotResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_web_scrape_html(self, async_client: AsyncContextDev) -> None: + web = await async_client.web.web_scrape_html( + url="https://example.com", + ) + assert_matches_type(WebWebScrapeHTMLResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_web_scrape_html(self, async_client: AsyncContextDev) -> None: + response = await async_client.web.with_raw_response.web_scrape_html( + url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = await response.parse() + assert_matches_type(WebWebScrapeHTMLResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_web_scrape_html(self, async_client: AsyncContextDev) -> None: + async with async_client.web.with_streaming_response.web_scrape_html( + url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = await response.parse() + assert_matches_type(WebWebScrapeHTMLResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_web_scrape_images(self, async_client: AsyncContextDev) -> None: + web = await async_client.web.web_scrape_images( + url="https://example.com", + ) + assert_matches_type(WebWebScrapeImagesResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_web_scrape_images(self, async_client: AsyncContextDev) -> None: + response = await async_client.web.with_raw_response.web_scrape_images( + url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = await response.parse() + assert_matches_type(WebWebScrapeImagesResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_web_scrape_images(self, async_client: AsyncContextDev) -> None: + async with async_client.web.with_streaming_response.web_scrape_images( + url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = await response.parse() + assert_matches_type(WebWebScrapeImagesResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_web_scrape_md(self, async_client: AsyncContextDev) -> None: + web = await async_client.web.web_scrape_md( + url="https://example.com", + ) + assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_web_scrape_md_with_all_params(self, async_client: AsyncContextDev) -> None: + web = await async_client.web.web_scrape_md( + url="https://example.com", + include_images=True, + include_links=True, + shorten_base64_images=True, + ) + assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_web_scrape_md(self, async_client: AsyncContextDev) -> None: + response = await async_client.web.with_raw_response.web_scrape_md( + url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = await response.parse() + assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_web_scrape_md(self, async_client: AsyncContextDev) -> None: + async with async_client.web.with_streaming_response.web_scrape_md( + url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = await response.parse() + assert_matches_type(WebWebScrapeMdResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_web_scrape_sitemap(self, async_client: AsyncContextDev) -> None: + web = await async_client.web.web_scrape_sitemap( + domain="domain", + ) + assert_matches_type(WebWebScrapeSitemapResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_web_scrape_sitemap(self, async_client: AsyncContextDev) -> None: + response = await async_client.web.with_raw_response.web_scrape_sitemap( + domain="domain", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + web = await response.parse() + assert_matches_type(WebWebScrapeSitemapResponse, web, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_web_scrape_sitemap(self, async_client: AsyncContextDev) -> None: + async with async_client.web.with_streaming_response.web_scrape_sitemap( + domain="domain", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + web = await response.parse() + assert_matches_type(WebWebScrapeSitemapResponse, web, path=["response"]) + + assert cast(Any, response.is_closed) is True