TerraGuard

Search API Reference

The standalone Search API service has been retired. Web and news search now run inside the Backend API as an internal module using Serper.dev (primary) and Brave Search (fallback).

Service retired

The standalone Search API service (tg-search-api) has been removed from the system. The POST /v1/search, GET /v1/health, and GET /v1/providers endpoints it exposed no longer exist, and there is no separate search service or port to call.

The previous design routed search through a standalone Go microservice backed by SearXNG (meta-searching Google/Bing/DuckDuckGo through a Tor SOCKS proxy) with Brave as a fallback. That entire stack — the service, the SearXNG container, and the Tor container — has been decommissioned.

What replaced it

Search is now an internal module of the Backend API (app/common/search_providers.py). It is called in-process by the backend — there is no HTTP endpoint and no dedicated port.

  • Primary provider — Serper.dev: POST https://google.serper.dev/search (web) and POST https://google.serper.dev/news (news). Auth via X-API-KEY: SERPER_API_KEY. Paginates ~10 results/page up to 10 pages (~100 results).
  • Fallback provider — Brave Search (called only when Serper errors): GET https://api.search.brave.com/res/v1/web/search (20/page) and GET https://api.search.brave.com/res/v1/news/search (50/page). Auth via X-Subscription-Token: BRAVE_API_KEY. Offset pagination 0–9.

Consumers call two entry points — search_web() and search_news() — which return a unified list[SearchResult]. The fallback is error-triggered only: a successful-but-empty Serper response does not invoke Brave.

from app.common.search_providers import search_web, search_news, age_to_freshness

results = await search_web("earthquake Turkey 2026", freshness=age_to_freshness(event.detected_at), limit=100)
news = await search_news("Cyclone Mocha landfall", limit=50)

Configuration is limited to two environment variables in the Backend API (app/config.py): SERPER_API_KEY and BRAVE_API_KEY. There is no SEARCH_API_URL, SEARXNG_URL, Tor, or residential proxy configuration.

Where to read more

For the full architecture of the current search layer — provider roles, the unified SearchResult model, freshness mapping, and configuration — see the Search Layer service page.

On this page