Tutorial

How to Track E-Commerce Prices Across Multiple Platforms

Track prices across Amazon, Walmart, and Google Shopping with one API. Python script with alerts and cross-platform comparison.

Tracking a product across Amazon, Walmart, and Google Shopping traditionally requires three APIs. A single API covering all platforms lets you build a unified tracker that detects cross-platform price gaps and alerts on drops. This tutorial builds one using the Scavio API at $0.005 per platform check -- tracking one product across three platforms costs $0.015 per cycle.

Prerequisites

  • Python 3.8+ or Node.js 18+
  • A Scavio API key from scavio.dev
  • requests library installed
  • Products to track

Walkthrough

Step 1: Define products and platforms

Set up products with platform-specific search queries.

Python
import os, json, requests
from datetime import datetime

API_KEY = os.environ['SCAVIO_API_KEY']
H = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

PRODUCTS = [
    {'name': 'Sony WH-1000XM5', 'queries': {
        'amazon': 'Sony WH-1000XM5 headphones',
        'walmart': 'Sony WH-1000XM5',
    }},
    {'name': 'AirPods Pro 2', 'queries': {
        'amazon': 'Apple AirPods Pro 2nd generation',
        'walmart': 'AirPods Pro 2',
    }},
]

Step 2: Fetch prices from each platform

Query each platform and extract price data.

Python
def fetch_price(query, platform):
    body = {'query': query, 'platform': platform, 'country_code': 'us'}
    if platform == 'amazon': body['marketplace'] = 'US'
    data = requests.post('https://api.scavio.dev/api/v1/search', headers=H, json=body).json()
    items = data.get('products', data.get('shopping_results', []))
    if not items: return None
    raw = str(items[0].get('price', '')).replace('$', '').replace(',', '')
    try: price = float(raw)
    except: price = None
    return {'title': items[0].get('title', ''), 'price': price, 'platform': platform}

Step 3: Compare prices and detect gaps

Find the cheapest platform and alert on significant price differences.

Python
def track_all():
    for product in PRODUCTS:
        print(f"\n{product['name']}:")
        prices = {}
        for platform, query in product['queries'].items():
            r = fetch_price(query, platform)
            if r and r['price']:
                prices[platform] = r['price']
                print(f"  {platform}: ${r['price']:.2f}")
            else:
                print(f"  {platform}: not found")
        if len(prices) >= 2:
            cheapest = min(prices, key=prices.get)
            gap = max(prices.values()) - min(prices.values())
            print(f"  Best: {cheapest} (${prices[cheapest]:.2f}), gap: ${gap:.2f}")
            if gap > 10: print(f"  ALERT: ${gap:.2f} price gap!")
    credits = sum(len(p['queries']) for p in PRODUCTS)
    print(f'\nCost: ${credits * 0.005:.3f}')

track_all()

Step 4: Store history and detect trends

Append results to a JSON log for trend analysis over time.

Python
def save_and_trend(product_name, prices, path='price_log.jsonl'):
    entry = {'product': product_name, 'prices': prices, 'ts': datetime.now().isoformat()}
    with open(path, 'a') as f: f.write(json.dumps(entry) + '\n')
    history = []
    with open(path) as f:
        for line in f:
            h = json.loads(line)
            if h['product'] == product_name: history.append(h)
    if len(history) >= 2:
        for p in prices:
            prev = history[-2]['prices'].get(p)
            curr = prices[p]
            if prev and curr:
                diff = curr - prev
                if abs(diff) > 1:
                    d = 'UP' if diff > 0 else 'DOWN'
                    print(f"  {p} trend: ${prev:.2f} -> ${curr:.2f} ({d})")

# Call after track_all with actual prices

Python Example

Python
import os, requests

API_KEY = os.environ['SCAVIO_API_KEY']
H = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

def price(query, platform):
    body = {'query': query, 'platform': platform, 'country_code': 'us'}
    if platform == 'amazon': body['marketplace'] = 'US'
    items = requests.post('https://api.scavio.dev/api/v1/search', headers=H, json=body).json().get('products', [])
    if not items: return None
    try: return float(str(items[0].get('price', '')).replace('$', '').replace(',', ''))
    except: return None

for name, q in [('Sony XM5', 'Sony WH-1000XM5'), ('AirPods Pro', 'AirPods Pro 2')]:
    print(f'{name}:')
    for p in ['amazon', 'walmart']:
        pr = price(q, p)
        print(f'  {p}: ${pr:.2f}' if pr else f'  {p}: N/A')

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY;
const H = { 'x-api-key': API_KEY, 'Content-Type': 'application/json' };

async function getPrice(query, platform) {
  const body = { query, platform, country_code: 'us' };
  if (platform === 'amazon') body.marketplace = 'US';
  const data = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: H, body: JSON.stringify(body)
  }).then(r => r.json());
  const item = (data.products || [])[0];
  if (!item) return null;
  const p = parseFloat(String(item.price || '').replace(/[$,]/g, ''));
  return isNaN(p) ? null : p;
}

async function track() {
  for (const [name, q] of [['Sony XM5', 'Sony WH-1000XM5'], ['AirPods', 'AirPods Pro 2']]) {
    console.log(`${name}:`);
    for (const p of ['amazon', 'walmart']) {
      const pr = await getPrice(q, p);
      console.log(`  ${p}: ${pr ? `$${pr.toFixed(2)}` : 'N/A'}`);
    }
  }
}
track().catch(console.error);

Expected Output

JSON
Sony WH-1000XM5:
  amazon: $298.00
  walmart: $278.00
  Best: walmart ($278.00), gap: $20.00
  ALERT: $20.00 price gap!

AirPods Pro 2:
  amazon: $189.99
  walmart: $189.99
  Best: amazon ($189.99), gap: $0.00

Cost: $0.020

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.8+ or Node.js 18+. A Scavio API key from scavio.dev. requests library installed. Products to track. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 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

Track prices across Amazon, Walmart, and Google Shopping with one API. Python script with alerts and cross-platform comparison.