Overview
AI agents that only search Google miss product prices, video trends, community sentiment, and social buzz. This workflow connects your agent to all 6 Scavio platforms through a single API key. The agent decides which platform to query based on the user's question, fetches live data, and synthesizes a cross-platform answer. One API key, one billing account, six data sources.
Trigger
Event-driven, on each user query to the agent.
Schedule
Event-driven
Workflow Steps
Classify User Query
Determine which platforms are relevant. Product questions hit Amazon and Walmart. Opinion questions hit Reddit. Trend questions hit TikTok and YouTube.
Route to Correct Platform
Call Scavio search API with the appropriate platform parameter. Use TikTok endpoint for TikTok queries.
Fetch Live Data
Execute the search and extract structured results: prices, ratings, views, upvotes, or engagement metrics.
Synthesize Cross-Platform Answer
Combine data from multiple platforms into a coherent answer with citations and data points.
Cache for Cost Efficiency
Cache results for 1 hour to avoid redundant API calls on repeated similar queries.
Python Implementation
import requests, os, json
from datetime import datetime, timedelta
API_KEY = os.environ["SCAVIO_API_KEY"]
H = {"x-api-key": API_KEY, "Content-Type": "application/json"}
TH = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
CACHE = {}
CACHE_TTL = timedelta(hours=1)
PLATFORM_RULES = {
"price": ["amazon", "walmart"],
"review": ["amazon", "reddit"],
"trend": ["tiktok", "youtube"],
"how to": ["youtube", "google"],
"opinion": ["reddit"],
"buy": ["amazon", "walmart", "google-shopping"],
}
def classify_query(query: str) -> list:
q = query.lower()
platforms = set()
for keyword, plats in PLATFORM_RULES.items():
if keyword in q:
platforms.update(plats)
return list(platforms) if platforms else ["google"]
def search_platform(query: str, platform: str) -> dict:
cache_key = f"{platform}:{query}"
if cache_key in CACHE and CACHE[cache_key]["expires"] > datetime.now():
return CACHE[cache_key]["data"]
if platform == "tiktok":
resp = requests.post(
"https://api.scavio.dev/api/v1/tiktok/search",
headers=TH,
json={"query": query},
timeout=15,
)
else:
resp = requests.post(
"https://api.scavio.dev/api/v1/search",
headers=H,
json={"query": query, "platform": platform},
timeout=15,
)
data = resp.json()
CACHE[cache_key] = {"data": data, "expires": datetime.now() + CACHE_TTL}
return data
def agent_search(query: str) -> dict:
platforms = classify_query(query)
results = {}
for p in platforms:
results[p] = search_platform(query, p)
return {"query": query, "platforms": platforms, "results": results}
answer = agent_search("best wireless earbuds price and reviews")
for p, data in answer["results"].items():
count = len(data.get("organic_results", data.get("results", [])))
print(f"{p}: {count} results")JavaScript Implementation
const H = {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'};
const TH = {'Authorization': 'Bearer '+process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'};
const CACHE = new Map();
const CACHE_TTL = 3600000; // 1 hour
const PLATFORM_RULES = {price:['amazon','walmart'], review:['amazon','reddit'], trend:['tiktok','youtube'], 'how to':['youtube','google'], opinion:['reddit'], buy:['amazon','walmart','google-shopping']};
function classifyQuery(query) {
const q = query.toLowerCase();
const platforms = new Set();
for (const [kw, plats] of Object.entries(PLATFORM_RULES)) {
if (q.includes(kw)) plats.forEach(p=>platforms.add(p));
}
return platforms.size ? [...platforms] : ['google'];
}
async function searchPlatform(query, platform) {
const key = platform+':'+query;
const cached = CACHE.get(key);
if (cached && cached.expires > Date.now()) return cached.data;
let r;
if (platform === 'tiktok') {
r = await fetch('https://api.scavio.dev/api/v1/tiktok/search', {method:'POST', headers:TH, body:JSON.stringify({query})});
} else {
r = await fetch('https://api.scavio.dev/api/v1/search', {method:'POST', headers:H, body:JSON.stringify({query, platform})});
}
const data = await r.json();
CACHE.set(key, {data, expires:Date.now()+CACHE_TTL});
return data;
}
async function agentSearch(query) {
const platforms = classifyQuery(query);
const results = {};
for (const p of platforms) results[p] = await searchPlatform(query, p);
return {query, platforms, results};
}
const answer = await agentSearch('best wireless earbuds price and reviews');
for (const [p, data] of Object.entries(answer.results)) {
const count = (data.organic_results || data.results || []).length;
console.log(p+': '+count+' results');
}Platforms Used
Web search with knowledge graph, PAA, and AI overviews
Amazon
Product search with prices, ratings, and reviews
YouTube
Video search with transcripts and metadata
Walmart
Product search with pricing and fulfillment data
Community, posts & threaded comments from any subreddit
TikTok
Trending video, creator, and product discovery