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 @@
{
".": "2.7.0"
".": "2.8.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 37
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-758c3a2fbd5b7be61c8e6e0ad2e6a5ec30695747bb675960d888c497647d13d7.yml
openapi_spec_hash: 00002d90bde02f67e174368ae470c597
config_hash: 2bea1743c84d63bd61f8501a6ea63065
configured_endpoints: 38
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-155e4761d62255841349c0f8a01b0a9c463ea1d1f2d6c4fd8d1a75c8bef6f226.yml
openapi_spec_hash: ab91f77e7c9d992400cbc7fc8a9e76c1
config_hash: bff282047fafdad771fb7ec685f56944
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 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)

### Features

* **api:** manual updates ([bbf6510](https://github.com/context-dot-dev/context-go-sdk/commit/bbf6510a615c1bb20ef80fe594b62e9faa1c3cd6))

## 2.7.0 (2026-08-01)

Full Changelog: [v2.6.0...v2.7.0](https://github.com/context-dot-dev/context-go-sdk/compare/v2.6.0...v2.7.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.7.0'
go get -u 'github.com/context-dot-dev/context-go-sdk@v2.8.0'
```

<!-- x-release-please-end -->
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ Response Types:

- <a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandGetResponse">BrandGetResponse</a>
- <a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandGetSimplifiedResponse">BrandGetSimplifiedResponse</a>
- <a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandSearchResponse">BrandSearchResponse</a>

Methods:

- <code title="post /brand/retrieve">client.Brand.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandGetParams">BrandGetParams</a>) (\*<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandGetResponse">BrandGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /brand/retrieve-simplified">client.Brand.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandService.GetSimplified">GetSimplified</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandGetSimplifiedParams">BrandGetSimplifiedParams</a>) (\*<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandGetSimplifiedResponse">BrandGetSimplifiedResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /brand/search">client.Brand.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandService.Search">Search</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandSearchParams">BrandSearchParams</a>) (\*<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2">contextdev</a>.<a href="https://pkg.go.dev/github.com/context-dot-dev/context-go-sdk/v2#BrandSearchResponse">BrandSearchResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Industry

Expand Down
100 changes: 100 additions & 0 deletions brand.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ func (r *BrandService) GetSimplified(ctx context.Context, query BrandGetSimplifi
return res, err
}

// 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
// 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
// fetch (and index) a specific domain. Free on Pro and Scale plans; costs 1 credit
// per request on the Free and Starter plans.
func (r *BrandService) Search(ctx context.Context, query BrandSearchParams, opts ...option.RequestOption) (res *BrandSearchResponse, err error) {
opts = slices.Concat(r.options, opts)
path := "brand/search"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return res, err
}

type BrandGetResponse struct {
// Detailed brand information
Brand BrandGetResponseBrand `json:"brand"`
Expand Down Expand Up @@ -861,6 +875,73 @@ func (r *BrandGetSimplifiedResponseKeyMetadata) UnmarshalJSON(data []byte) error
return apijson.UnmarshalRoot(data, r)
}

type BrandSearchResponse struct {
// Up to 10 matching brands, most popular first. 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.
KeyMetadata BrandSearchResponseKeyMetadata `json:"key_metadata"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Results respjson.Field
KeyMetadata respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

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

type BrandSearchResponseResult struct {
// The brand's domain.
Domain string `json:"domain" api:"required"`
// Logo link URL that serves the brand's logo, generated per request for the
// calling organization.
Logo string `json:"logo" api:"required"`
// The brand's name. Empty string when unknown.
Name string `json:"name" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Domain respjson.Field
Logo respjson.Field
Name respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

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

// 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.
type BrandSearchResponseKeyMetadata struct {
// The number of credits consumed by this request.
CreditsConsumed int64 `json:"credits_consumed" api:"required"`
// The number of credits remaining for your organization after this request.
CreditsRemaining int64 `json:"credits_remaining" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CreditsConsumed respjson.Field
CreditsRemaining respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

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

type BrandGetParams struct {

//
Expand Down Expand Up @@ -1337,3 +1418,22 @@ const (
BrandGetSimplifiedParamsThemeLight BrandGetSimplifiedParamsTheme = "light"
BrandGetSimplifiedParamsThemeDark BrandGetSimplifiedParamsTheme = "dark"
)

type BrandSearchParams struct {
// Search term, matched against brand names and domains by prefix (e.g. 'nike',
// 'nike.com', 'nik').
Query string `query:"query" api:"required" json:"-"`
// Optional comma-separated caller-defined tags for tracking this request. Tags are
// recorded on the request's usage log and can be used to filter usage on the
// dashboard usage page. Up to 20 tags, each 1-50 characters.
Tags []string `query:"tags,omitzero" json:"-"`
paramObj
}

// URLQuery serializes [BrandSearchParams]'s query parameters as `url.Values`.
func (r BrandSearchParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
26 changes: 26 additions & 0 deletions brand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,29 @@ func TestBrandGetSimplifiedWithOptionalParams(t *testing.T) {
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestBrandSearchWithOptionalParams(t *testing.T) {
t.Skip("Mock server tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := contextdev.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
_, err := client.Brand.Search(context.TODO(), contextdev.BrandSearchParams{
Query: "x",
Tags: []string{"production", "team-alpha"},
})
if err != nil {
var apierr *contextdev.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
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.7.0" // x-release-please-version
const PackageVersion = "2.8.0" // x-release-please-version
Loading