ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Build Automated Competitor Price Tracker
Tutorial

How to Build Automated Competitor Price Tracker

Track competitor pricing changes across Google Shopping, Amazon, and Walmart. Daily alerts for price drops and increases.

Get Free API KeyAPI Docs

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.

Python
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.

Python
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.

Python
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

Python
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

JavaScript
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

JSON
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

Related Tutorials

  • How to Build a Cross-Platform Price Tracker
  • How to Build a Multi-Platform Price Monitor
  • How to Build an Ecommerce Price Tracker with Scavio

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+. requests library. A Scavio API key from scavio.dev. List of products and competitor brands to track. A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, 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.

Related Resources

Best Of

Best API for Cross-Platform Price Monitoring in 2026

Read more
Best Of

Best E-Commerce Price Tracking API in 2026

Read more
Solution

Monitor Competitor Pricing Across Marketplaces

Read more
Solution

Track Prices Across Amazon, Walmart, and Google Shopping

Read more
Use Case

Cross-Platform Product Price Monitoring

Read more
Use Case

Multi-Platform Price Tracking

Read more

Start Building

Track competitor pricing changes across Google Shopping, Amazon, and Walmart. Daily alerts for price drops and increases.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy