ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Workflows
  3. Search Backend Failover Chain
Workflow

Search Backend Failover Chain

Automated search failover: try primary provider, fall back to secondary on error. Python and JS implementations.

Start FreeAPI Docs

Overview

Try a primary search provider, fall back to a secondary on timeout or error, and log which provider served each request. Useful for agents that need reliable search without manual intervention when a provider goes down.

Trigger

Agent search request

Schedule

On-demand (per agent request)

Workflow Steps

1

Call primary provider

Send query to primary search API with a 5-second timeout.

2

Check response validity

Verify response contains results and status is 200.

3

Fallback on failure

If primary fails or times out, call secondary provider.

4

Log provider used

Record which provider served the request for cost tracking.

Python Implementation

Python
import requests, os, time

H = {"x-api-key": os.environ["SCAVIO_API_KEY"]}

def search_with_fallback(query, platform="google"):
    try:
        r = requests.post("https://api.scavio.dev/api/v1/search",
            headers=H, json={"platform": platform, "query": query}, timeout=5)
        r.raise_for_status()
        return {"provider": "scavio", "results": r.json()}
    except Exception:
        pass
    # Fallback: Brave Search API
    try:
        r2 = requests.get("https://api.search.brave.com/res/v1/web/search",
            headers={"X-Subscription-Token": os.environ["BRAVE_KEY"]},
            params={"q": query}, timeout=5)
        r2.raise_for_status()
        return {"provider": "brave", "results": r2.json()}
    except Exception:
        return {"provider": "none", "results": []}

result = search_with_fallback("best CRM tools 2026")
print(f"Served by: {result['provider']}")

JavaScript Implementation

JavaScript
const search = async (query) => {
  try {
    const r = await fetch("https://api.scavio.dev/api/v1/search", {
      method: "POST", headers: {"x-api-key": process.env.SCAVIO_API_KEY, "Content-Type": "application/json"},
      body: JSON.stringify({platform: "google", query}), signal: AbortSignal.timeout(5000)
    });
    if (r.ok) return {provider: "scavio", results: await r.json()};
  } catch {}
  try {
    const r2 = await fetch(`https://api.search.brave.com/res/v1/web/search?q=${encodeURIComponent(query)}`, {
      headers: {"X-Subscription-Token": process.env.BRAVE_KEY}, signal: AbortSignal.timeout(5000)
    });
    if (r2.ok) return {provider: "brave", results: await r2.json()};
  } catch {}
  return {provider: "none", results: []};
};

Platforms Used

Google

Web search with knowledge graph, PAA, and AI overviews

Frequently Asked Questions

Try a primary search provider, fall back to a secondary on timeout or error, and log which provider served each request. Useful for agents that need reliable search without manual intervention when a provider goes down.

This workflow uses a agent search request. On-demand (per agent request).

This workflow uses the following Scavio platforms: google. Each platform is called via the same unified API endpoint.

Yes. Scavio's free tier includes 50 credits on signup with no credit card required. That is enough to test and validate this workflow before scaling it.

Search Backend Failover Chain

Automated search failover: try primary provider, fall back to secondary on error. Python and JS implementations.

Get Your API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy