Simple Go CLI for Brave Search API, designed for agent-friendly usage.
- Calls Brave endpoints:
GET /res/v1/web/search(search)GET /res/v1/news/search(news)GET /res/v1/images/search(images)GET /res/v1/videos/search(videos)
- Resolves API key in this order:
--api-keyBRAVE_API_KEY(orBRAVE_SEARCH_API_KEY)~/.brave-search/key
- Stores config in
~/.brave-search/config.json - Stores cache in
~/.brave-search/cache/ - Retries
429 Too Many Requestsautomatically with backoff
- Go
1.23+
just installOr:
./scripts/install.shThe installer builds ./cmd/bravesearch and installs the binary at:
~/.local/bin/bravesearchIf ~/.local/bin is not in your PATH, add it:
export PATH="$HOME/.local/bin:$PATH"You can also choose a custom location:
./scripts/install.sh --bin-dir /usr/local/binjust buildOr:
go build -o bravesearch ./cmd/bravesearchrm -f ~/.local/bin/bravesearchAny one of these works:
./bravesearch search --api-key "$KEY" --q "golang"export BRAVE_API_KEY="$KEY"
./bravesearch search --q "golang"mkdir -p ~/.brave-search
printf '%s\n' "$KEY" > ~/.brave-search/key
chmod 600 ~/.brave-search/key
./bravesearch search --q "golang"Run Brave web search.
./bravesearch search --q "site:go.dev context cancellation"./bravesearch search --q "golang http client timeout" --count 5 --output titlesUseful flags:
--q,--query: query text--count: 1-20--offset: 0-9--country,--search-lang,--ui-lang--safesearch:off|moderate|strict--freshness--spellcheck(defaulttrue)--extra-snippets--summary--enable-rich-callback--result-filter--goggle(repeatable)--param key=value(repeatable raw pass-through)--output:json|pretty|urls|titles(defaultjson)--no-cache--refresh--cache-ttl(for example30m)--timeout(for example20s)--api-version(optional BraveApi-Versionheader)--max-retries(retry attempts on429, default3)
Run Brave news search.
./bravesearch news --q "federal reserve inflation outlook" --count 10news supports up to --count 50. It includes core flags plus:
--extra-snippets--goggle(repeatable)
Run Brave image search.
./bravesearch images --q "golden gate bridge fog" --count 30images supports up to --count 200.
Run Brave video search.
./bravesearch videos --q "go concurrency patterns" --count 10videos supports up to --count 50.
Manage settings in ~/.brave-search/config.json.
./bravesearch config init
./bravesearch config show
./bravesearch config get default_count
./bravesearch config set default_count 10
./bravesearch config set cache_ttl 30m
./bravesearch config pathsSupported keys:
base_urltimeoutcache_ttlcache_enableddefault_countrydefault_search_langdefault_ui_langdefault_safesearchdefault_countapi_version
Manage cache files in ~/.brave-search/cache/.
./bravesearch cache stats
./bravesearch cache prune
./bravesearch cache clear- Default output is raw JSON for easier machine parsing.
- Cache key is based on request URL + API version.
--output urls|titlesis supported only for thesearchcommand.