Price tracking across Amazon and Walmart requires monitoring the same products on both platforms and comparing prices over time. Manual checking is impractical at scale. This tutorial builds an automated tracker that queries both platforms via Scavio's API, compares prices, and alerts on drops or arbitrage opportunities. The same API key covers both platforms with a consistent response format.
Prerequisites
- Python 3.8+ installed
- requests library installed
- A Scavio API key from scavio.dev
- A list of products to track
Walkthrough
Step 1: Define your product catalog
List the products you want to track across both platforms.
import os
API_KEY = os.environ['SCAVIO_API_KEY']
PRODUCTS = [
'Sony WH-1000XM5',
'Apple AirPods Pro 2',
'Samsung Galaxy S26',
'Nintendo Switch 2',
]Step 2: Search both platforms for each product
Query Amazon and Walmart for each product and extract pricing data.
import requests
H = {'x-api-key': API_KEY}
def get_prices(product: str) -> dict:
result = {'product': product}
for platform in ['amazon', 'walmart']:
resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': platform, 'query': product}, timeout=10)
top = resp.json().get('organic', [{}])[0]
result[platform] = {
'title': top.get('title', ''),
'price': top.get('price'),
'url': top.get('link', ''),
'rating': top.get('rating'),
}
return resultStep 3: Calculate price differentials
Compare prices across platforms and flag arbitrage opportunities.
def analyze_prices(price_data: dict, min_margin: float = 0.10) -> dict:
amazon_price = price_data.get('amazon', {}).get('price')
walmart_price = price_data.get('walmart', {}).get('price')
if amazon_price and walmart_price and amazon_price > 0 and walmart_price > 0:
diff = abs(amazon_price - walmart_price)
margin = diff / max(amazon_price, walmart_price)
cheaper = 'amazon' if amazon_price < walmart_price else 'walmart'
price_data['analysis'] = {
'cheaper_on': cheaper,
'price_diff': round(diff, 2),
'margin': round(margin * 100, 1),
'arbitrage': margin >= min_margin,
}
else:
price_data['analysis'] = {'error': 'price data incomplete'}
return price_dataStep 4: Run daily and save history
Execute the tracker daily and store results for trend analysis.
import json, datetime
def daily_track():
date = datetime.date.today().isoformat()
results = []
for product in PRODUCTS:
data = get_prices(product)
analyzed = analyze_prices(data)
results.append(analyzed)
if analyzed.get('analysis', {}).get('arbitrage'):
a = analyzed['analysis']
print(f'ARBITRAGE: {product} - ${a["price_diff"]} cheaper on {a["cheaper_on"]} ({a["margin"]}% margin)')
with open(f'prices_{date}.json', 'w') as f:
json.dump(results, f, indent=2)
return results
daily_track()Python Example
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}
def compare_prices(product):
prices = {}
for p in ['amazon', 'walmart']:
data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': p, 'query': product}, timeout=10).json()
top = data.get('organic', [{}])[0]
prices[p] = top.get('price')
return prices
print(compare_prices('Sony WH-1000XM5'))JavaScript Example
async function comparePrices(product) {
const prices = {};
for (const p of ['amazon', 'walmart']) {
const data = 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: p, query: product})
}).then(r => r.json());
prices[p] = data.organic?.[0]?.price;
}
return prices;
}Expected Output
A daily price tracker comparing Amazon and Walmart prices with arbitrage alerts.