Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.9.0"
".": "1.10.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev%2Fcontext.dev-a831ece9950c336fba69327e01aed391a08418e1898f4aff27a800471f139cc7.yml
openapi_spec_hash: 459258410b739536cdc75b91e8b4eac7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-1c5074f316b556d15dca19f0a7c5b9238c698d6f3e20b42bec67f122a97764cc.yml
openapi_spec_hash: 8e1dd204746bcfaaf637d93b1d339eb2
config_hash: 70354330f92ce169beabc98696ebb9a3
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.10.0 (2026-05-01)

Full Changelog: [v1.9.0...v1.10.0](https://github.com/context-dot-dev/context-ruby-sdk/compare/v1.9.0...v1.10.0)

### Features

* **api:** api update ([c74cbf3](https://github.com/context-dot-dev/context-ruby-sdk/commit/c74cbf354e15c2b56680b4248ed69462a1a84d23))
* **api:** api update ([cc57672](https://github.com/context-dot-dev/context-ruby-sdk/commit/cc576729ce6c522ee578e7dc5f99122463014515))
* support setting headers via env ([e625fee](https://github.com/context-dot-dev/context-ruby-sdk/commit/e625fee97a6d4f6ab25f69447b33521cac6a896c))

## 1.9.0 (2026-04-25)

Full Changelog: [v1.8.0...v1.9.0](https://github.com/context-dot-dev/context-ruby-sdk/compare/v1.8.0...v1.9.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
context.dev (1.9.0)
context.dev (1.10.0)
cgi
connection_pool

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "context.dev", "~> 1.9.0"
gem "context.dev", "~> 1.10.0"
```

<!-- x-release-please-end -->
Expand Down
16 changes: 15 additions & 1 deletion lib/context_dev/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,28 @@ def initialize(
raise ArgumentError.new("api_key is required, and can be set via environ: \"CONTEXT_DEV_API_KEY\"")
end

headers = {}
custom_headers_env = ENV["CONTEXT_DEV_CUSTOM_HEADERS"]
unless custom_headers_env.nil?
parsed = {}
custom_headers_env.split("\n").each do |line|
colon = line.index(":")
unless colon.nil?
parsed[line[0...colon].strip] = line[(colon + 1)..].strip
end
end
headers = parsed.merge(headers)
end

@api_key = api_key.to_s

super(
base_url: base_url,
timeout: timeout,
max_retries: max_retries,
initial_retry_delay: initial_retry_delay,
max_retry_delay: max_retry_delay
max_retry_delay: max_retry_delay,
headers: headers
)

@web = ContextDev::Resources::Web.new(client: self)
Expand Down
12 changes: 11 additions & 1 deletion lib/context_dev/models/ai_extract_product_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,29 @@ class AIExtractProductParams < ContextDev::Internal::Type::BaseModel
# @return [String]
required :url, String

# @!attribute max_age_ms
# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
#
# @return [Integer, nil]
optional :max_age_ms, Integer, api_name: :maxAgeMs

# @!attribute timeout_ms
# Optional timeout in milliseconds for the request. Maximum allowed value is
# 300000ms (5 minutes).
#
# @return [Integer, nil]
optional :timeout_ms, Integer, api_name: :timeoutMS

# @!method initialize(url:, timeout_ms: nil, request_options: {})
# @!method initialize(url:, max_age_ms: nil, timeout_ms: nil, request_options: {})
# Some parameter documentations has been truncated, see
# {ContextDev::Models::AIExtractProductParams} for more details.
#
# @param url [String] The product page URL to extract product data from.
#
# @param max_age_ms [Integer] Return a cached result if a prior scrape for the same parameters exists and is y
#
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. Maximum allowed value is 30000
#
# @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}]
Expand Down
24 changes: 22 additions & 2 deletions lib/context_dev/models/ai_extract_products_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ class ByDomain < ContextDev::Internal::Type::BaseModel
# @return [String]
required :domain, String

# @!attribute max_age_ms
# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
#
# @return [Integer, nil]
optional :max_age_ms, Integer, api_name: :maxAgeMs

# @!attribute max_products
# Maximum number of products to extract.
#
Expand All @@ -43,12 +51,14 @@ class ByDomain < ContextDev::Internal::Type::BaseModel
# @return [Integer, nil]
optional :timeout_ms, Integer, api_name: :timeoutMS

# @!method initialize(domain:, max_products: nil, timeout_ms: nil)
# @!method initialize(domain:, max_age_ms: nil, max_products: nil, timeout_ms: nil)
# Some parameter documentations has been truncated, see
# {ContextDev::Models::AIExtractProductsParams::Body::ByDomain} for more details.
#
# @param domain [String] The domain name to analyze.
#
# @param max_age_ms [Integer] Return a cached result if a prior scrape for the same parameters exists and is y
#
# @param max_products [Integer] Maximum number of products to extract.
#
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. Maximum allowed value is 30000
Expand All @@ -62,6 +72,14 @@ class ByDirectURL < ContextDev::Internal::Type::BaseModel
# @return [String]
required :direct_url, String, api_name: :directUrl

# @!attribute max_age_ms
# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
#
# @return [Integer, nil]
optional :max_age_ms, Integer, api_name: :maxAgeMs

# @!attribute max_products
# Maximum number of products to extract.
#
Expand All @@ -75,13 +93,15 @@ class ByDirectURL < ContextDev::Internal::Type::BaseModel
# @return [Integer, nil]
optional :timeout_ms, Integer, api_name: :timeoutMS

# @!method initialize(direct_url:, max_products: nil, timeout_ms: nil)
# @!method initialize(direct_url:, max_age_ms: nil, max_products: nil, timeout_ms: nil)
# Some parameter documentations has been truncated, see
# {ContextDev::Models::AIExtractProductsParams::Body::ByDirectURL} for more
# details.
#
# @param direct_url [String] A specific URL to use directly as the starting point for extraction without doma
#
# @param max_age_ms [Integer] Return a cached result if a prior scrape for the same parameters exists and is y
#
# @param max_products [Integer] Maximum number of products to extract.
#
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. Maximum allowed value is 30000
Expand Down
15 changes: 8 additions & 7 deletions lib/context_dev/resources/ai.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ def ai_query(params)
# Some parameter documentations has been truncated, see
# {ContextDev::Models::AIExtractProductParams} for more details.
#
# 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.
# Given a single URL, determines if it is a product page and extracts the product
# information.
#
# @overload extract_product(url:, timeout_ms: nil, request_options: {})
# @overload extract_product(url:, max_age_ms: nil, timeout_ms: nil, request_options: {})
#
# @param url [String] The product page URL to extract product data from.
#
# @param max_age_ms [Integer] Return a cached result if a prior scrape for the same parameters exists and is y
#
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. Maximum allowed value is 30000
#
# @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}, nil]
Expand All @@ -65,9 +66,9 @@ def extract_product(params)
)
end

# Beta feature: Extract product information from a brand's website. We will
# analyze the website and return a list of products with details such as name,
# description, image, pricing, features, and more.
# Extract product information from a brand's website. We will analyze the website
# and return a list of products with details such as name, description, image,
# pricing, features, and more.
#
# @overload extract_products(body:, request_options: {})
#
Expand Down
4 changes: 2 additions & 2 deletions lib/context_dev/resources/industry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def retrieve_naics(params)
# {ContextDev::Models::IndustryRetrieveSicParams} for more details.
#
# Classify any brand into Standard Industrial Classification (SIC) codes from its
# domain or name. Choose between the original 1987 SIC system (`original_sic`) or
# the latest SIC list maintained by the SEC (`latest_sec`).
# domain or name. Choose between the original SIC system (`original_sic`) or the
# latest SIC list maintained by the SEC (`latest_sec`).
#
# @overload retrieve_sic(input:, max_results: nil, min_results: nil, timeout_ms: nil, type: nil, request_options: {})
#
Expand Down
8 changes: 2 additions & 6 deletions lib/context_dev/resources/utility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class Utility
# {ContextDev::Models::UtilityPrefetchParams} for more details.
#
# 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]
# latency.
#
# @overload prefetch(domain:, timeout_ms: nil, request_options: {})
#
Expand Down Expand Up @@ -39,9 +37,7 @@ def prefetch(params)
# 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]
# domain for prefetching.
#
# @overload prefetch_by_email(email:, timeout_ms: nil, request_options: {})
#
Expand Down
2 changes: 1 addition & 1 deletion lib/context_dev/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ContextDev
VERSION = "1.9.0"
VERSION = "1.10.0"
end
15 changes: 15 additions & 0 deletions rbi/context_dev/models/ai_extract_product_params.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ module ContextDev
sig { returns(String) }
attr_accessor :url

# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
sig { returns(T.nilable(Integer)) }
attr_reader :max_age_ms

sig { params(max_age_ms: Integer).void }
attr_writer :max_age_ms

# Optional timeout in milliseconds for the request. Maximum allowed value is
# 300000ms (5 minutes).
sig { returns(T.nilable(Integer)) }
Expand All @@ -29,13 +38,18 @@ module ContextDev
sig do
params(
url: String,
max_age_ms: Integer,
timeout_ms: Integer,
request_options: ContextDev::RequestOptions::OrHash
).returns(T.attached_class)
end
def self.new(
# The product page URL to extract product data from.
url:,
# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
max_age_ms: nil,
# Optional timeout in milliseconds for the request. Maximum allowed value is
# 300000ms (5 minutes).
timeout_ms: nil,
Expand All @@ -47,6 +61,7 @@ module ContextDev
override.returns(
{
url: String,
max_age_ms: Integer,
timeout_ms: Integer,
request_options: ContextDev::RequestOptions
}
Expand Down
42 changes: 40 additions & 2 deletions rbi/context_dev/models/ai_extract_products_params.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ module ContextDev
sig { returns(String) }
attr_accessor :domain

# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
sig { returns(T.nilable(Integer)) }
attr_reader :max_age_ms

sig { params(max_age_ms: Integer).void }
attr_writer :max_age_ms

# Maximum number of products to extract.
sig { returns(T.nilable(Integer)) }
attr_reader :max_products
Expand All @@ -94,13 +103,18 @@ module ContextDev
sig do
params(
domain: String,
max_age_ms: Integer,
max_products: Integer,
timeout_ms: Integer
).returns(T.attached_class)
end
def self.new(
# The domain name to analyze.
domain:,
# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
max_age_ms: nil,
# Maximum number of products to extract.
max_products: nil,
# Optional timeout in milliseconds for the request. Maximum allowed value is
Expand All @@ -111,7 +125,12 @@ module ContextDev

sig do
override.returns(
{ domain: String, max_products: Integer, timeout_ms: Integer }
{
domain: String,
max_age_ms: Integer,
max_products: Integer,
timeout_ms: Integer
}
)
end
def to_hash
Expand All @@ -132,6 +151,15 @@ module ContextDev
sig { returns(String) }
attr_accessor :direct_url

# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
sig { returns(T.nilable(Integer)) }
attr_reader :max_age_ms

sig { params(max_age_ms: Integer).void }
attr_writer :max_age_ms

# Maximum number of products to extract.
sig { returns(T.nilable(Integer)) }
attr_reader :max_products
Expand All @@ -150,6 +178,7 @@ module ContextDev
sig do
params(
direct_url: String,
max_age_ms: Integer,
max_products: Integer,
timeout_ms: Integer
).returns(T.attached_class)
Expand All @@ -158,6 +187,10 @@ module ContextDev
# A specific URL to use directly as the starting point for extraction without
# domain resolution.
direct_url:,
# Return a cached result if a prior scrape for the same parameters exists and is
# younger than this many milliseconds. Defaults to 7 days (604800000 ms) when
# omitted. Max is 30 days (2592000000 ms). Set to 0 to always scrape fresh.
max_age_ms: nil,
# Maximum number of products to extract.
max_products: nil,
# Optional timeout in milliseconds for the request. Maximum allowed value is
Expand All @@ -168,7 +201,12 @@ module ContextDev

sig do
override.returns(
{ direct_url: String, max_products: Integer, timeout_ms: Integer }
{
direct_url: String,
max_age_ms: Integer,
max_products: Integer,
timeout_ms: Integer
}
)
end
def to_hash
Expand Down
Loading
Loading