Price monitoring for Google Shopping products is useful for personal buying decisions, competitive intelligence, and e-commerce arbitrage. Building your own price alert system lets you track specific products and get notified when prices drop below your threshold. This tutorial shows how to query Google Shopping via the Scavio API, store price history, detect price changes, and trigger alerts. You will build a pipeline that runs on a schedule and notifies you of significant price movements.
Prerequisites
- Python 3.8+ installed
- requests library installed
- A Scavio API key from scavio.dev
- A list of products to monitor
Walkthrough
Step 1: Define products to monitor
Set up the products and target prices you want to track.
import os, requests, json
from datetime import date
API_KEY = os.environ["SCAVIO_API_KEY"]
WATCHLIST = [
{"query": "Sony WH-1000XM5", "target_price": 250.00},
{"query": "Apple AirPods Pro 2", "target_price": 180.00},
{"query": "Samsung Galaxy Buds 3", "target_price": 120.00},
]
HISTORY_FILE = "price_history.json"Step 2: Fetch current prices
Query Google Shopping for each product and extract the lowest current price.
def get_prices(product_query):
resp = requests.post("https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "google", "query": product_query, "type": "shopping"})
results = resp.json().get("shopping_results", [])[:10]
prices = []
for r in results:
price_str = r.get("price", "").replace("$", "").replace(",", "")
try:
prices.append({"title": r["title"], "price": float(price_str),
"seller": r.get("source", ""), "link": r.get("link", "")})
except ValueError:
continue
return sorted(prices, key=lambda x: x["price"])Step 3: Track price history
Store prices over time to detect trends and drops.
def load_history():
try:
with open(HISTORY_FILE) as f:
return json.load(f)
except FileNotFoundError:
return {}
def save_price(query, prices):
history = load_history()
if query not in history:
history[query] = []
if prices:
history[query].append({
"date": date.today().isoformat(),
"lowest": prices[0]["price"],
"seller": prices[0]["seller"],
})
with open(HISTORY_FILE, "w") as f:
json.dump(history, f, indent=2)Step 4: Check alerts and notify
Compare current prices against target prices and previous prices to detect drops.
def check_alerts(watchlist):
alerts = []
for item in watchlist:
prices = get_prices(item["query"])
if not prices: continue
lowest = prices[0]["price"]
save_price(item["query"], prices)
if lowest <= item["target_price"]:
alerts.append({
"product": item["query"],
"price": lowest,
"target": item["target_price"],
"seller": prices[0]["seller"],
"link": prices[0]["link"],
})
print(f"ALERT: {item['query']} at ${lowest} (target: ${item['target_price']})")
else:
print(f"{item['query']}: ${lowest} (target: ${item['target_price']})")
return alerts
alerts = check_alerts(WATCHLIST)Python Example
import os, requests
API_KEY = os.environ["SCAVIO_API_KEY"]
def lowest_price(query):
resp = requests.post("https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "google", "query": query, "type": "shopping"})
results = resp.json().get("shopping_results", [])[:5]
prices = []
for r in results:
try: prices.append(float(r.get("price","0").replace("$","").replace(",","")))
except: pass
return min(prices) if prices else None
print(f"Lowest: ${lowest_price('Sony WH-1000XM5')}")JavaScript Example
const H = {"x-api-key": process.env.SCAVIO_API_KEY, "Content-Type": "application/json"};
async function lowestPrice(query) {
const r = await fetch("https://api.scavio.dev/api/v1/search", {
method: "POST", headers: H,
body: JSON.stringify({platform: "google", query, type: "shopping"})
});
const items = (await r.json()).shopping_results || [];
const prices = items.map(i => parseFloat((i.price||"0").replace(/[$,]/g,""))).filter(Boolean);
return Math.min(...prices);
}
lowestPrice("Sony WH-1000XM5").then(p => console.log("Lowest: $" + p));Expected Output
A price monitoring pipeline that tracks Google Shopping prices, stores history, detects drops, and alerts when products hit target price thresholds.