Skip to content
Open
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 @@
{
".": "2.8.0"
".": "2.9.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: 38
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-155e4761d62255841349c0f8a01b0a9c463ea1d1f2d6c4fd8d1a75c8bef6f226.yml
openapi_spec_hash: ab91f77e7c9d992400cbc7fc8a9e76c1
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-c1b6ca84f9bec1b1936cebb61f058924c3d7a5f6977e4cd76cf0544c4c7d8737.yml
openapi_spec_hash: 141bfa8430ddccfb5a37c4bd703d163b
config_hash: bff282047fafdad771fb7ec685f56944
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 2.9.0 (2026-08-06)

Full Changelog: [v2.8.0...v2.9.0](https://github.com/context-dot-dev/context-go-sdk/compare/v2.8.0...v2.9.0)

### Features

* **api:** api update ([e1a197f](https://github.com/context-dot-dev/context-go-sdk/commit/e1a197fe3667d68af27bd368470f743eee85ec01))
* **api:** api update ([e4803c4](https://github.com/context-dot-dev/context-go-sdk/commit/e4803c4cf0aebf68aeb1653630e60e39caae68c1))
* **api:** api update ([46f18c2](https://github.com/context-dot-dev/context-go-sdk/commit/46f18c27fb20790758beb40150fba47971a91a5a))
* **api:** api update ([bd340b8](https://github.com/context-dot-dev/context-go-sdk/commit/bd340b8ad89d0530f3a8396d4ec3f380fc4137d5))
* **api:** api update ([e71dbb9](https://github.com/context-dot-dev/context-go-sdk/commit/e71dbb9625e935c311e8ab0f57bb112791b3b1cf))
* **api:** api update ([f15add2](https://github.com/context-dot-dev/context-go-sdk/commit/f15add299d50c81d179afdfdcda99eb9687aaa31))

## 2.8.0 (2026-08-05)

Full Changelog: [v2.7.0...v2.8.0](https://github.com/context-dot-dev/context-go-sdk/compare/v2.7.0...v2.8.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/context-dot-dev/context-go-sdk@v2.8.0'
go get -u 'github.com/context-dot-dev/context-go-sdk@v2.9.0'
```

<!-- x-release-please-end -->
Expand Down
23 changes: 19 additions & 4 deletions batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,12 @@ func (r *BatchGetResponse) UnmarshalJSON(data []byte) error {

// What this batch has done to your credit balance.
type BatchGetResponseCredits struct {
// `reserved` minus `refunded` — what the batch has cost so far. Equal to
// `reserved` until the batch settles.
// `reserved` minus `refunded` plus `ocr_charged` — what the batch has cost so far.
// Equal to `reserved` until the batch settles.
Net int64 `json:"net" api:"required"`
// Credits charged for PDF pages recovered by OCR (pdf.ocr=true), 1 per recovered
// page, on top of `reserved`. Stays 0 until the batch settles.
OcrCharged int64 `json:"ocr_charged" api:"required"`
// Credits returned for pages that did not succeed. Stays 0 until the batch reaches
// a final status, then settles in one movement.
Refunded int64 `json:"refunded" api:"required"`
Expand All @@ -367,6 +370,7 @@ type BatchGetResponseCredits struct {
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Net respjson.Field
OcrCharged respjson.Field
Refunded respjson.Field
Reserved respjson.Field
ExtraFields map[string]respjson.Field
Expand Down Expand Up @@ -637,9 +641,12 @@ func (r *BatchListResponseData) UnmarshalJSON(data []byte) error {

// What this batch has done to your credit balance.
type BatchListResponseDataCredits struct {
// `reserved` minus `refunded` — what the batch has cost so far. Equal to
// `reserved` until the batch settles.
// `reserved` minus `refunded` plus `ocr_charged` — what the batch has cost so far.
// Equal to `reserved` until the batch settles.
Net int64 `json:"net" api:"required"`
// Credits charged for PDF pages recovered by OCR (pdf.ocr=true), 1 per recovered
// page, on top of `reserved`. Stays 0 until the batch settles.
OcrCharged int64 `json:"ocr_charged" api:"required"`
// Credits returned for pages that did not succeed. Stays 0 until the batch reaches
// a final status, then settles in one movement.
Refunded int64 `json:"refunded" api:"required"`
Expand All @@ -649,6 +656,7 @@ type BatchListResponseDataCredits struct {
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Net respjson.Field
OcrCharged respjson.Field
Refunded respjson.Field
Reserved respjson.Field
ExtraFields map[string]respjson.Field
Expand Down Expand Up @@ -995,6 +1003,8 @@ type BatchGetResultsResponseDataUnion struct {
// This field is from variant [BatchGetResultsResponseDataOk].
Markdown string `json:"markdown"`
Meta any `json:"meta"`
// This field is from variant [BatchGetResultsResponseDataOk].
OcrPages int64 `json:"ocr_pages"`
// This field is from variant [BatchGetResultsResponseDataError].
ErrorCode string `json:"error_code"`
// This field is from variant [BatchGetResultsResponseDataError].
Expand All @@ -1009,6 +1019,7 @@ type BatchGetResultsResponseDataUnion struct {
ItemID respjson.Field
Markdown respjson.Field
Meta respjson.Field
OcrPages respjson.Field
ErrorCode respjson.Field
Message respjson.Field
raw string
Expand Down Expand Up @@ -1080,6 +1091,9 @@ type BatchGetResultsResponseDataOk struct {
Markdown string `json:"markdown"`
// Caller-supplied metadata echoed from submission.
Meta map[string]any `json:"meta"`
// PDF pages of this document recovered by OCR (pdf.ocr=true). Each recovered page
// bills 1 credit on top of the page base credit; absent when no OCR ran.
OcrPages int64 `json:"ocr_pages"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
FinalURL respjson.Field
Expand All @@ -1091,6 +1105,7 @@ type BatchGetResultsResponseDataOk struct {
ItemID respjson.Field
Markdown respjson.Field
Meta respjson.Field
OcrPages respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
Expand Down
33 changes: 31 additions & 2 deletions brand.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func (r *BrandService) GetSimplified(ctx context.Context, query BrandGetSimplifi
}

// Search brands by name or domain and get back up to 10 lightweight matches
// (domain, name, logo), most popular first: by Tranco rank, then market cap for
// (domain, name, logo). Name matches rank ahead of domain matches; within each
// group the most popular brands come first: by Tranco rank, then market cap for
// brands outside the Tranco list, with text relevance breaking ties. Matching is
// prefix-based with no typo tolerance, so it is suited to autocomplete. Only
// brands already in the Context.dev index are returned — use /brand/retrieve to
Expand Down Expand Up @@ -113,6 +114,8 @@ type BrandGetResponseBrand struct {
Domain string `json:"domain"`
// Company email address
Email string `json:"email"`
// Employee headcount information for the brand (will be null if unknown)
Employees BrandGetResponseBrandEmployees `json:"employees"`
// Industry classification information for the brand
Industries BrandGetResponseBrandIndustries `json:"industries"`
// Indicates whether the brand content is not safe for work (NSFW)
Expand Down Expand Up @@ -161,6 +164,7 @@ type BrandGetResponseBrand struct {
Description respjson.Field
Domain respjson.Field
Email respjson.Field
Employees respjson.Field
Industries respjson.Field
IsNsfw respjson.Field
Links respjson.Field
Expand Down Expand Up @@ -305,6 +309,30 @@ func (r *BrandGetResponseBrandColor) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// Employee headcount information for the brand (will be null if unknown)
type BrandGetResponseBrandEmployees struct {
// Exact employee count when a precise headcount is known
Exact int64 `json:"exact"`
// Employee count range for the brand (e.g. '11 to 50')
//
// Any of "1 to 10", "11 to 50", "51 to 200", "201 to 500", "501 to 1000", "1001 to
// 5000", "5001 to 10000", "10001+".
Range string `json:"range"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Exact respjson.Field
Range respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r BrandGetResponseBrandEmployees) RawJSON() string { return r.JSON.raw }
func (r *BrandGetResponseBrandEmployees) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// Industry classification information for the brand
type BrandGetResponseBrandIndustries struct {
// Easy Industry Classification - array of industry and subindustry pairs
Expand Down Expand Up @@ -876,7 +904,8 @@ func (r *BrandGetSimplifiedResponseKeyMetadata) UnmarshalJSON(data []byte) error
}

type BrandSearchResponse struct {
// Up to 10 matching brands, most popular first. Empty when nothing matches.
// Up to 10 matching brands, name matches first, then domain matches, most popular
// first within each group. Empty when nothing matches.
Results []BrandSearchResponseResult `json:"results" api:"required"`
// Metadata about the API key used for the request. Included in every response
// whenever a valid API key is provided, even when the response status is not 200.
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "2.8.0" // x-release-please-version
const PackageVersion = "2.9.0" // x-release-please-version
9 changes: 5 additions & 4 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ type ParseHandleParams struct {
IncludeImages ParseHandleParamsIncludeImagesUnion `query:"includeImages,omitzero" json:"-"`
// Preserve hyperlinks in Markdown output
IncludeLinks ParseHandleParamsIncludeLinksUnion `query:"includeLinks,omitzero" json:"-"`
// When true for PDF inputs, detect and OCR images embedded in the selected pages,
// inserting recognized text at each image's position in page reading order while
// preserving the PDF text layer. pdf.start/pdf.end limit the inclusive page range.
// When false, all OCR is disabled, including the automatic scanned-PDF fallback.
// When true for PDF inputs, OCR the selected pages that have no usable text layer
// (scans), replacing each recovered page's text with the OCR result while pages
// with a real text layer keep it. pdf.start/pdf.end limit the inclusive page
// range. Billed at 1 credit per page OCR actually recovered, on top of the base
// request cost. When false, no OCR runs.
Ocr ParseHandleParamsOcrUnion `query:"ocr,omitzero" json:"-"`
// PDF page-range options as a JSON object, e.g. {"start": 2, "end": 5}.
Pdf ParseHandleParamsPdf `query:"pdf,omitzero" json:"-"`
Expand Down
54 changes: 40 additions & 14 deletions web.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ func (r *WebService) WebScrapeImages(ctx context.Context, query WebWebScrapeImag
// responses from a recognized API key; use error_code to distinguish stable
// failure categories.
//
// ### YouTube
//
// YouTube URLs return the video or channel itself rather than the surrounding
// player and navigation chrome. A URL addressing a single video (`/watch`,
// `youtu.be`, `/shorts`, `/embed`, `/live`) returns its title, channel, duration,
// view count, keywords, full description, and the transcript when the video has
// captions that can be retrieved; videos without captions return everything except
// the transcript. A channel URL (`/channel/UC…`, `/@handle`, `/c/…`, `/user/…`)
// returns its name, handle, subscriber count, video count, and full description.
// When `includeImages=true`, video responses also include the thumbnail and
// channel responses include the avatar. Costs the same as any other scrape.
//
// ### Billing & errors
//
// | HTTP status | Billed? | Meaning |
Expand All @@ -132,6 +144,7 @@ func (r *WebService) WebScrapeImages(ctx context.Context, query WebWebScrapeImag
// | 401 / 403 | No | Invalid/disabled key, insufficient permissions, or credits exhausted; inspect error_code |
// | 404 | No | Target page returned or fingerprinted as not found |
// | 408 | No | Request timed out |
// | 413 | No | Target content exceeds the maximum supported size (20 MB) |
// | 415 | No | Unsupported content type |
// | 429 | No | Per-minute rate limit exceeded; honor Retry-After |
// | 500 | No | Internal error |
Expand All @@ -142,7 +155,11 @@ func (r *WebService) WebScrapeMd(ctx context.Context, query WebWebScrapeMdParams
return res, err
}

// Crawl an entire website's sitemap and return all discovered page URLs.
// Crawl an entire website's sitemap and return all discovered page URLs. Pass
// `search` to have the crawled sitemap filtered down to the pages about a phrase
// (for example `pricing and plans` or `api authentication docs`), most relevant
// first — a searched crawl scans the whole sitemap and costs 2 credits instead
// of 1.
func (r *WebService) WebScrapeSitemap(ctx context.Context, query WebWebScrapeSitemapParams, opts ...option.RequestOption) (res *WebWebScrapeSitemapResponse, err error) {
opts = slices.Concat(r.options, opts)
path := "web/scrape/sitemap"
Expand Down Expand Up @@ -1248,7 +1265,8 @@ func (r *WebSearchResponseResult) UnmarshalJSON(data []byte) error {
type WebSearchResponseResultMarkdown struct {
// Per-result scrape outcome. Inspect this before reading `markdown`.
//
// Any of "SUCCESS", "NOT_REQUESTED", "TIMEOUT", "WEBSITE_ACCESS_ERROR", "ERROR".
// Any of "SUCCESS", "NOT_REQUESTED", "TIMEOUT", "CONTENT_TOO_LARGE",
// "WEBSITE_ACCESS_ERROR", "ERROR".
Code string `json:"code" api:"required"`
// GFM Markdown of the page. Null unless markdownOptions.enabled is true and
// scraping succeeded.
Expand Down Expand Up @@ -2369,7 +2387,8 @@ type WebWebScrapeSitemapResponse struct {
//
// Any of true.
Success bool `json:"success" api:"required"`
// Array of discovered page URLs from the sitemap (max 500)
// Discovered page URLs from the sitemap, up to `maxLinks`. When `search` is set
// these are only the matching pages, most relevant first.
URLs []string `json:"urls" api:"required"`
// Metadata about the API key used for the request. Included in every response
// whenever a valid API key is provided, even when the response status is not 200.
Expand Down Expand Up @@ -3704,9 +3723,10 @@ type WebWebCrawlMdParamsPdf struct {
// Last 1-based PDF page to parse. When omitted, parsing ends at the last page.
// Must be greater than or equal to start when both are provided.
End param.Opt[int64] `json:"end,omitzero"`
// When true, detect and OCR images embedded in the selected PDF pages, inserting
// recognized text at each image's position in page reading order while preserving
// the PDF text layer. This is separate from automatic scanned-PDF OCR fallback.
// When true, OCR the selected PDF pages that have no usable text layer (scans),
// replacing each recovered page's text with the OCR result while pages with a real
// text layer keep it. Billed at 1 credit per page OCR actually recovered, on top
// of the base request cost.
Ocr param.Opt[bool] `json:"ocr,omitzero"`
// When true, PDF pages are fetched and parsed. When false, PDF pages are skipped
// entirely (not included in results and not counted as failures).
Expand Down Expand Up @@ -4111,12 +4131,13 @@ type WebWebScrapeHTMLParamsPdf struct {
End param.Opt[int64] `query:"end,omitzero" json:"-"`
// First 1-based PDF page to parse. When omitted, parsing starts at the first page.
Start param.Opt[int64] `query:"start,omitzero" json:"-"`
// When true, detect and OCR images embedded in the selected PDF pages, inserting
// recognized text at each image's position in page reading order while preserving
// the PDF text layer. This is separate from automatic scanned-PDF OCR fallback.
// When true, OCR the selected PDF pages that have no usable text layer (scans),
// replacing each recovered page's text with the OCR result while pages with a real
// text layer keep it. Billed at 1 credit per page OCR actually recovered, on top
// of the base request cost. When false, no OCR runs.
Ocr WebWebScrapeHTMLParamsPdfOcrUnion `query:"ocr,omitzero" json:"-"`
// When true, PDF URLs are fetched and parsed. When false, PDF URLs are skipped and
// a 400 WEBSITE_ACCESS_ERROR is returned.
// a 400 PDF_SKIPPED is returned.
ShouldParse WebWebScrapeHTMLParamsPdfShouldParseUnion `query:"shouldParse,omitzero" json:"-"`
paramObj
}
Expand Down Expand Up @@ -4828,12 +4849,13 @@ type WebWebScrapeMdParamsPdf struct {
End param.Opt[int64] `query:"end,omitzero" json:"-"`
// First 1-based PDF page to parse. When omitted, parsing starts at the first page.
Start param.Opt[int64] `query:"start,omitzero" json:"-"`
// When true, detect and OCR images embedded in the selected PDF pages, inserting
// recognized text at each image's position in page reading order while preserving
// the PDF text layer. This is separate from automatic scanned-PDF OCR fallback.
// When true, OCR the selected PDF pages that have no usable text layer (scans),
// replacing each recovered page's text with the OCR result while pages with a real
// text layer keep it. Billed at 1 credit per page OCR actually recovered, on top
// of the base request cost. When false, no OCR runs.
Ocr WebWebScrapeMdParamsPdfOcrUnion `query:"ocr,omitzero" json:"-"`
// When true, PDF URLs are fetched and parsed. When false, PDF URLs are skipped and
// a 400 WEBSITE_ACCESS_ERROR is returned.
// a 400 PDF_SKIPPED is returned.
ShouldParse WebWebScrapeMdParamsPdfShouldParseUnion `query:"shouldParse,omitzero" json:"-"`
paramObj
}
Expand Down Expand Up @@ -4954,6 +4976,10 @@ type WebWebScrapeSitemapParams struct {
// Maximum number of links to return from the sitemap crawl. Defaults to 10,000.
// Minimum is 1, maximum is 100,000.
MaxLinks param.Opt[int64] `query:"maxLinks,omitzero" json:"-"`
// Optional search phrase. When provided, the crawled sitemap is filtered to the
// pages whose URLs are about that phrase, most relevant first, and the request
// costs 2 credits instead of 1.
Search param.Opt[string] `query:"search,omitzero" json:"-"`
// Optional explicit sitemap URL. When provided, exactly this sitemap is crawled
// instead of discovering the domain's sitemaps.
SitemapURL param.Opt[string] `query:"sitemapUrl,omitzero" format:"uri" json:"-"`
Expand Down
1 change: 1 addition & 0 deletions web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ func TestWebWebScrapeSitemapWithOptionalParams(t *testing.T) {
"foo": "J!",
},
MaxLinks: contextdev.Int(1),
Search: contextdev.String("help center and troubleshooting articles"),
SitemapURL: contextdev.String("https://example.com"),
Tags: []string{"production", "team-alpha"},
TimeoutMs: contextdev.Int(1),
Expand Down
Loading