Multi-key Brave Search with automatic round-robin rotation and rate-limit fallback.
Set env var with comma-separated keys:
export BRAVE_API_KEYS=key1,key2,key3
Optionally set state file path (default: ~/.brave_key_state.json):
export BRAVE_KEY_STATE_FILE=/path/to/state.json
scripts/brave_search.pyRun directly or import as module.
python3 brave_search.py "your query" [--count 5] [--type web|news|image] [--country us] [--lang en] [--json]
import sys, os
sys.path.insert(0, "path/to/skill/scripts")
from brave_search import search, format_results
data, used_key, key_idx = search("your query", count=5, search_type="web")
results = format_results(data, "web")
# results = [{"title": ..., "url": ..., "snippet": ...}, ...]
~/.brave_key_state.jsoncat ~/.brave_key_state.json
Shows per-key request count, last success, and blocked_until timestamps.
| Type | Endpoint | Result fields |
|---|---|---|
| ------- | ----------------------- | -------------------------------------- |
| web | /web/search | title, url, snippet |
| news | /news/search | title, url, snippet, age |
| image | /images/search | title, url, thumbnail |
references/brave-api.md for full API params and plan details共 1 个版本