brave

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package brave wires Brave's Web Search API into web.Searcher.

Endpoint

GET https://api.search.brave.com/res/v1/web/search

Authentication uses the X-Subscription-Token header (not bearer).

Parameter mapping

web.SearchRequest → Brave query parameters:

  • Query → q (after Google-style site:/-site: rewriting)
  • MaxResults → count (default 10 when omitted)
  • AllowedDomains → inlined as `site:foo.com` operators
  • BlockedDomains → inlined as `-site:foo.com` operators
  • Recency → freshness=pd/pw/pm/py (hour collapses to "pd" since Brave's minimum granularity is "past day")

Brave has no native allow/block-domain fields, so the query is rewritten with site:/-site: like the Serper provider does.

Response mapping

Brave web.results[] → []*web.SearchResult:

  • title → Title
  • url → URL
  • description → Snippet
  • page_age → PublishedTime (RFC3339; the human-readable "age" field is dropped because relative strings like "2 hours ago" don't parse)

The provider deliberately owns and hides Brave's transport DTOs; only the normalized web result vertical crosses the package boundary.

Why Brave

Brave runs its own independent index (not a Google/Bing reseller), so adding it gives the agent a result source that doesn't drift with the Google duopoly. Pricing is friendly: ~2000 queries/month free, sub-cent per query on paid tiers.

Reference

https://api-dashboard.search.brave.com/app/documentation/web-search/get-started

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config Config) (*Client, error)

func (*Client) Search

func (c *Client) Search(ctx context.Context, request *web.SearchRequest) (*web.SearchResponse, error)

type Config

type Config struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL