Competitor pricing changes daily, and manual checks do not scale. This tracker queries Google Shopping, Amazon, and Walmart for your product category, logs prices, detects changes, and sends alerts. Each platform check costs $0.005, so monitoring 20 products across 3 platforms costs $0.30/day.
Prerequisites
- Python 3.8+
- requests library
- A Scavio API key from scavio.dev
- List of products and competitor brands to track
Walkthrough
Step 1: Fetch prices from multiple platforms
Query Google Shopping, Amazon, and Walmart for product prices.
import os, requests, json
from datetime import datetime
API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
PRODUCTS = ['wireless earbuds', 'mechanical keyboard', 'USB-C hub']
def get_prices(product, platform=None):
body = {'query': product, 'country_code': 'us'}
if platform:
body['platform'] = platform
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json=body).json()
results = data.get('shopping_results', data.get('organic_results', []))
prices = []
for r in results[:5]:
price = r.get('price', r.get('extracted_price', ''))
prices.append({
'title': r.get('title', '')[:60],
'price': price,
'source': r.get('source', r.get('displayed_link', '')),
'link': r.get('link', ''),
'platform': platform or 'google'
})
return prices
for product in PRODUCTS:
print(f'\n{product}:')
for platform in [None, 'amazon', 'walmart']:
prices = get_prices(product, platform)
label = platform or 'google'
if prices:
lowest = min(prices, key=lambda p: float(str(p['price']).replace('$', '').replace(',', '') or '999'))
print(f' [{label:8}] {len(prices)} listings, lowest: {lowest["price"]} - {lowest["title"][:35]}')
else:
print(f' [{label:8}] No results')
print(f'\nCost: ${len(PRODUCTS) * 3 * 0.005:.3f}')Step 2: Detect price changes vs baseline
Compare current prices against stored baselines and flag changes.
def track_price_changes(products, history_file='price_history.json'):
try:
with open(history_file) as f:
history = json.load(f)
except FileNotFoundError:
history = {}
today = datetime.now().strftime('%Y-%m-%d')
changes = []
for product in products:
prices = get_prices(product, 'amazon')
if not prices:
continue
top_price = prices[0]
price_val = str(top_price.get('price', '')).replace('$', '').replace(',', '')
try:
price_num = float(price_val)
except ValueError:
continue
key = f'{product}_amazon'
if key in history:
prev = history[key]['price']
if abs(price_num - prev) > 0.01:
pct = (price_num - prev) / prev * 100
direction = 'UP' if price_num > prev else 'DOWN'
changes.append({
'product': product, 'prev': prev, 'current': price_num,
'change_pct': pct, 'direction': direction
})
history[key] = {'price': price_num, 'date': today, 'title': top_price['title']}
with open(history_file, 'w') as f:
json.dump(history, f, indent=2)
if changes:
print(f'\n=== Price Changes Detected ===')
for c in changes:
print(f' [{c["direction"]:4}] {c["product"]}: ${c["prev"]:.2f} -> ${c["current"]:.2f} ({c["change_pct"]:+.1f}%)')
else:
print(f'\nNo price changes detected (or first scan).')
return changes
track_price_changes(PRODUCTS)Step 3: Generate price comparison report
Create a cross-platform price comparison for each product.
def price_comparison_report(products):
print(f'\n=== Cross-Platform Price Report - {datetime.now().strftime("%Y-%m-%d")} ===')
for product in products:
print(f'\n {product.upper()}')
all_prices = []
for platform in [None, 'amazon', 'walmart']:
prices = get_prices(product, platform)
all_prices.extend(prices)
# Sort by price
for p in all_prices:
try:
p['price_num'] = float(str(p['price']).replace('$', '').replace(',', ''))
except (ValueError, TypeError):
p['price_num'] = 999
all_prices.sort(key=lambda x: x['price_num'])
for p in all_prices[:5]:
print(f' ${p["price_num"]:8.2f} | {p["platform"]:8} | {p["title"][:35]}')
if len(all_prices) >= 2:
spread = all_prices[-1]['price_num'] - all_prices[0]['price_num']
print(f' Price spread: ${spread:.2f}')
total_queries = len(products) * 3
print(f'\n Total cost: ${total_queries * 0.005:.3f} ({total_queries} queries)')
price_comparison_report(PRODUCTS)Python Example
import os, requests
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def check_price(product, platform='amazon'):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': product, 'platform': platform, 'country_code': 'us'}).json()
results = data.get('organic_results', [])[:3]
for r in results:
print(f' {r.get("price", "N/A")} - {r.get("title", "")[:40]}')
check_price('wireless earbuds')
print('Cost: $0.005')JavaScript Example
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
const data = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: SH,
body: JSON.stringify({ query: 'wireless earbuds', platform: 'amazon', country_code: 'us' })
}).then(r => r.json());
(data.organic_results || []).slice(0, 3).forEach(r =>
console.log(`${r.price || 'N/A'} - ${(r.title || '').slice(0, 40)}`));Expected Output
wireless earbuds:
[google ] 5 listings, lowest: $14.99 - JBL Tune Buds Wireless Earbuds
[amazon ] 5 listings, lowest: $17.99 - Samsung Galaxy Buds FE
[walmart ] 5 listings, lowest: $12.88 - onn. TWS Earbuds
Cost: $0.045
=== Cross-Platform Price Report ===
WIRELESS EARBUDS
$ 12.88 | walmart | onn. TWS Earbuds
$ 14.99 | google | JBL Tune Buds Wireless Earbuds
$ 17.99 | amazon | Samsung Galaxy Buds FE
Price spread: $15.11