Tutorial

How to Search Across Google, Amazon, YouTube, and Walmart with One API

Use the Scavio API to search Google, Amazon, YouTube, and Walmart from a single endpoint. Build a unified search layer for AI agents and data pipelines.

Many applications need data from multiple search platforms: Google for web context, Amazon for product pricing, YouTube for video content, and Walmart for retail alternatives. Managing four separate API integrations — each with different authentication, rate limits, and response schemas — is complex and expensive. The Scavio API provides a single endpoint that unifies all four platforms under a consistent interface. This tutorial builds a unified search function that queries all four platforms and returns a normalized result set.

Prerequisites

  • Python 3.10 or higher
  • requests library installed
  • A Scavio API key
  • Basic understanding of concurrent Python programming

Walkthrough

Step 1: Define platform request configs

Create a helper that builds the correct request body for each platform from a single query string.

Python
def platform_body(platform: str, query: str) -> dict:
    base = {"platform": platform, "query": query}
    if platform == "google":
        return {"query": query, "country_code": "us"}
    if platform == "amazon":
        return {**base, "marketplace": "US"}
    return base

Step 2: Fan out requests concurrently

Query all four platforms simultaneously using ThreadPoolExecutor to minimize latency.

Python
from concurrent.futures import ThreadPoolExecutor

PLATFORMS = ["google", "amazon", "youtube", "walmart"]

def search_all(query: str) -> dict:
    def fetch(platform):
        r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY},
                          json=platform_body(platform, query))
        r.raise_for_status()
        return r.json()
    with ThreadPoolExecutor(max_workers=4) as ex:
        futs = {p: ex.submit(fetch, p) for p in PLATFORMS}
        return {p: f.result() for p, f in futs.items()}

Step 3: Extract result counts per platform

Build a summary showing how many results each platform returned for the query.

Python
def summarize(results: dict) -> dict:
    return {
        "google": len(results["google"].get("organic_results", [])),
        "amazon": len(results["amazon"].get("products", [])),
        "youtube": len(results["youtube"].get("videos", [])),
        "walmart": len(results["walmart"].get("products", [])),
    }

Step 4: Print a unified summary

Display the result counts and top item from each platform.

Python
results = search_all("portable bluetooth speaker")
counts = summarize(results)
for platform, count in counts.items():
    print(f"{platform}: {count} results")

Python Example

Python
import os
import requests
from concurrent.futures import ThreadPoolExecutor

API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"

def body(platform: str, query: str) -> dict:
    if platform == "google": return {"query": query, "country_code": "us"}
    if platform == "amazon": return {"platform": platform, "query": query, "marketplace": "US"}
    return {"platform": platform, "query": query}

def search_all(query: str) -> dict:
    def fetch(p): 
        r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY}, json=body(p, query))
        r.raise_for_status()
        return r.json()
    with ThreadPoolExecutor(max_workers=4) as ex:
        futs = {p: ex.submit(fetch, p) for p in ["google", "amazon", "youtube", "walmart"]}
        return {p: f.result() for p, f in futs.items()}

if __name__ == "__main__":
    data = search_all("portable bluetooth speaker")
    print(f"Google: {len(data['google'].get('organic_results', []))} results")
    print(f"Amazon: {len(data['amazon'].get('products', []))} products")
    print(f"YouTube: {len(data['youtube'].get('videos', []))} videos")
    print(f"Walmart: {len(data['walmart'].get('products', []))} products")

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";

function body(platform, query) {
  if (platform === "google") return { query, country_code: "us" };
  if (platform === "amazon") return { platform, query, marketplace: "US" };
  return { platform, query };
}

async function fetchPlatform(platform, query) {
  const res = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify(body(platform, query))
  });
  return [platform, await res.json()];
}

async function searchAll(query) {
  const platforms = ["google", "amazon", "youtube", "walmart"];
  const results = await Promise.all(platforms.map(p => fetchPlatform(p, query)));
  return Object.fromEntries(results);
}

searchAll("portable bluetooth speaker").then(data => {
  console.log(`Google: ${data.google.organic_results?.length || 0} results`);
  console.log(`Amazon: ${data.amazon.products?.length || 0} products`);
  console.log(`YouTube: ${data.youtube.videos?.length || 0} videos`);
  console.log(`Walmart: ${data.walmart.products?.length || 0} products`);
}).catch(console.error);

Expected Output

JSON
Google: 10 results
Amazon: 20 products
YouTube: 10 videos
Walmart: 16 products

Top Amazon: JBL Flip 6 Portable Speaker — $79.95
Top Walmart: Anker Soundcore 3 — $35.99

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.10 or higher. requests library installed. A Scavio API key. Basic understanding of concurrent Python programming. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Use the Scavio API to search Google, Amazon, YouTube, and Walmart from a single endpoint. Build a unified search layer for AI agents and data pipelines.