Usage¶
Python API¶
from search_smith import search
results = search("Python semantic release", count=10)
for result in results:
print(result.title)
print(result.url)
print(result.snippet)
Explicit Brave Client¶
from search_smith import BraveSearch
with BraveSearch() as client:
results = client.search("Brave Search API", count=5)
Constructor arguments take precedence over environment variables. Use this when your application has already loaded the secret from a safe runtime source:
import os
client = BraveSearch(api_key=os.environ["BRAVE_SEARCH_API_KEY"])
CLI¶
search-smith "Python semantic release"
search-smith "Cretan fact checking" --count 5
search-smith "Brave Search API" --format json
Text output is meant for terminals. JSON output is a stable list of normalized result objects.
Result Model¶
Each result is a SearchResult:
SearchResult(
title="Example",
url="https://example.com",
snippet="Short result excerpt.",
source="brave",
rank=1,
score=None,
metadata={},
)
metadata preserves useful provider-specific fields that are not part of the
provider-neutral model.