Track a product's lifecycle across marketplaces by querying Amazon, Walmart, and Google through a single API and recording price, review count, rating, and availability at regular intervals. This reveals launch timing differences between marketplaces, price erosion patterns, and review velocity curves that inform inventory and marketing decisions. Scavio's multi-platform API makes this possible with one API key instead of maintaining separate scrapers for each marketplace. This tutorial builds a lifecycle tracker that polls multiple platforms and generates a timeline report.
Prerequisites
- Python 3.8+ installed
- requests library installed
- A Scavio API key from scavio.dev
- A product name or ASIN to track
Walkthrough
Step 1: Define the product and platforms
Set up the product to track and the marketplaces to query. Use the same search term across all platforms for consistency.
import os, requests, json, datetime
API_KEY = os.environ['SCAVIO_API_KEY']
PRODUCT = 'Sony WH-1000XM6'
PLATFORMS = ['amazon', 'walmart', 'google']
HISTORY_FILE = 'product_lifecycle.json'Step 2: Query each marketplace
Search for the product on each platform and extract the primary listing's price, rating, and availability.
def query_marketplace(product: str, platform: str) -> dict:
resp = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': API_KEY},
json={'platform': platform, 'query': product}, timeout=15)
resp.raise_for_status()
results = resp.json().get('organic_results', [])
if not results:
return {'platform': platform, 'found': False}
top = results[0]
return {
'platform': platform,
'found': True,
'title': top.get('title', ''),
'price': top.get('price', ''),
'rating': top.get('rating', ''),
'reviews': top.get('reviews', ''),
'url': top.get('link', ''),
}Step 3: Record daily snapshots
Append today's data from all platforms to a JSON history file that accumulates over time.
def record_snapshot(product: str) -> dict:
snapshot = {
'date': datetime.date.today().isoformat(),
'product': product,
'platforms': [query_marketplace(product, p) for p in PLATFORMS],
}
history = []
try:
with open(HISTORY_FILE) as f:
history = json.load(f)
except FileNotFoundError:
pass
history.append(snapshot)
with open(HISTORY_FILE, 'w') as f:
json.dump(history, f, indent=2)
return snapshot
snap = record_snapshot(PRODUCT)
for p in snap['platforms']:
status = f"${p.get('price', 'N/A')} - {p.get('rating', 'N/A')} stars" if p['found'] else 'Not found'
print(f"{p['platform']}: {status}")Step 4: Generate the lifecycle timeline
Read the history file and print a timeline showing how pricing and reviews evolved across marketplaces.
def print_timeline(history_file: str = HISTORY_FILE):
with open(history_file) as f:
history = json.load(f)
print(f'Lifecycle timeline for {history[0]["product"]} ({len(history)} snapshots)\n')
for entry in history:
print(f'--- {entry["date"]} ---')
for p in entry['platforms']:
if p['found']:
print(f" {p['platform']:<10} price={p.get('price', 'N/A'):<10} rating={p.get('rating', 'N/A'):<6} reviews={p.get('reviews', 'N/A')}")
else:
print(f" {p['platform']:<10} NOT LISTED")
print()
print_timeline()Python Example
import requests, os, json
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}
def check_product(product, platform):
data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': platform, 'query': product}).json()
top = (data.get('organic_results', []) or [{}])[0]
return {'platform': platform, 'price': top.get('price', ''), 'rating': top.get('rating', '')}
for p in ['amazon', 'walmart', 'google']:
print(check_product('Sony WH-1000XM6', p))JavaScript Example
const H = {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'};
async function checkProduct(product, platform) {
const r = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: H, body: JSON.stringify({platform, query: product})
});
const top = ((await r.json()).organic_results || [])[0] || {};
return {platform, price: top.price || '', rating: top.rating || ''};
}
for (const p of ['amazon', 'walmart', 'google']) {
checkProduct('Sony WH-1000XM6', p).then(console.log);
}Expected Output
A JSON timeline showing daily price, rating, and review snapshots for a product across Amazon, Walmart, and Google, revealing lifecycle patterns.