Knowing when a product goes out of stock on Amazon but remains available on Walmart (or vice versa) is critical for arbitrage sellers, resellers, and procurement teams. This tutorial builds a cross-platform product tracker that checks availability and price on both Amazon and Walmart via the Scavio API, logs changes over time, and alerts when stock status changes or significant price differences emerge between platforms. Two API calls per product per check, $0.01 total per product.
Prerequisites
- Python 3.8+ or Node.js 18+
- A Scavio API key from scavio.dev
- requests library installed (Python)
- Product names or identifiers to track
Walkthrough
Step 1: Define products to track
Create a list of products with search terms. The same query will be used for both Amazon and Walmart lookups.
import os, json, requests
from datetime import datetime
API_KEY = os.environ['SCAVIO_API_KEY']
ENDPOINT = 'https://api.scavio.dev/api/v1/search'
HEADERS = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
PRODUCTS = [
'PlayStation 5 Digital Edition',
'Nintendo Switch OLED',
'Dyson V15 Detect',
]Step 2: Fetch product data from both platforms
Query Amazon and Walmart for each product. Extract price, availability, title, and rating from whichever result best matches the query.
def fetch_product(query, platform):
body = {'platform': platform, 'query': query}
if platform == 'amazon':
body['marketplace'] = 'US'
resp = requests.post(ENDPOINT, headers=HEADERS, json=body).json()
products = resp.get('products', [])
if not products:
return None
p = products[0]
raw_price = str(p.get('price', '')).replace('$', '').replace(',', '')
try:
price = float(raw_price)
except (ValueError, TypeError):
price = None
return {
'title': p.get('title', ''),
'price': price,
'availability': p.get('availability', 'Unknown'),
'rating': p.get('rating', ''),
'platform': platform,
}Step 3: Compare platforms and detect changes
Load previous state from a JSON file, compare against current data, and flag price changes, stock changes, and cross-platform price gaps.
def track_products():
state_file = 'product_state.json'
try:
with open(state_file) as f:
prev_state = json.load(f)
except FileNotFoundError:
prev_state = {}
current_state = {}
for product in PRODUCTS:
amazon = fetch_product(product, 'amazon')
walmart = fetch_product(product, 'walmart')
current_state[product] = {'amazon': amazon, 'walmart': walmart,
'checked_at': datetime.now().isoformat()}
prev = prev_state.get(product, {})
for platform, data in [('amazon', amazon), ('walmart', walmart)]:
if not data:
print(f'[MISSING] {product} not found on {platform}')
continue
prev_data = prev.get(platform)
if prev_data and prev_data.get('price') and data['price']:
diff = data['price'] - prev_data['price']
if abs(diff) > 1.0:
direction = 'UP' if diff > 0 else 'DOWN'
print(f'[PRICE {direction}] {product} on {platform}: '
f'${prev_data["price"]} -> ${data["price"]}')
print(f'[{platform.upper()}] {product}: ${data["price"]} - {data["availability"]}')
if amazon and walmart and amazon['price'] and walmart['price']:
gap = abs(amazon['price'] - walmart['price'])
if gap > 10:
cheaper = 'amazon' if amazon['price'] < walmart['price'] else 'walmart'
print(f' GAP: ${gap:.2f} difference, {cheaper} is cheaper')
with open(state_file, 'w') as f:
json.dump(current_state, f, indent=2)
return current_state
track_products()Python Example
import os, json, requests
from datetime import datetime
API_KEY = os.environ['SCAVIO_API_KEY']
ENDPOINT = 'https://api.scavio.dev/api/v1/search'
H = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
PRODUCTS = ['PlayStation 5 Digital Edition', 'Nintendo Switch OLED']
def fetch(query, platform):
body = {'platform': platform, 'query': query}
if platform == 'amazon': body['marketplace'] = 'US'
items = requests.post(ENDPOINT, headers=H, json=body).json().get('products', [])
if not items: return None
raw = str(items[0].get('price', '')).replace('$', '').replace(',', '')
try: price = float(raw)
except ValueError: price = None
return {'title': items[0].get('title', ''), 'price': price,
'availability': items[0].get('availability', 'Unknown')}
def track():
for p in PRODUCTS:
amz = fetch(p, 'amazon')
wmt = fetch(p, 'walmart')
for name, data in [('Amazon', amz), ('Walmart', wmt)]:
if data:
print(f'{name}: {p} -> ${data["price"]} ({data["availability"]})')
else:
print(f'{name}: {p} -> not found')
if amz and wmt and amz['price'] and wmt['price']:
gap = abs(amz['price'] - wmt['price'])
if gap > 5:
print(f' Price gap: ${gap:.2f}')
track()JavaScript Example
const API_KEY = process.env.SCAVIO_API_KEY;
const H = { 'x-api-key': API_KEY, 'Content-Type': 'application/json' };
const PRODUCTS = ['PlayStation 5 Digital Edition', 'Nintendo Switch OLED'];
async function fetchProduct(query, platform) {
const body = { platform, query };
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 items = data.products || [];
if (!items[0]) return null;
const price = parseFloat(String(items[0].price || '').replace(/[$,]/g, ''));
return { title: items[0].title, price: isNaN(price) ? null : price,
availability: items[0].availability || 'Unknown' };
}
async function track() {
for (const p of PRODUCTS) {
const amz = await fetchProduct(p, 'amazon');
const wmt = await fetchProduct(p, 'walmart');
console.log(`Amazon: ${p} -> $${amz?.price} (${amz?.availability})`);
console.log(`Walmart: ${p} -> $${wmt?.price} (${wmt?.availability})`);
if (amz?.price && wmt?.price) {
const gap = Math.abs(amz.price - wmt.price);
if (gap > 5) console.log(` Price gap: $${gap.toFixed(2)}`);
}
}
}
track().catch(console.error);Expected Output
[AMAZON] PlayStation 5 Digital Edition: $449.99 - In Stock
[WALMART] PlayStation 5 Digital Edition: $449.99 - In Stock
[AMAZON] Nintendo Switch OLED: $349.99 - In Stock
[WALMART] Nintendo Switch OLED: $339.99 - In Stock
GAP: $10.00 difference, walmart is cheaper
[PRICE DOWN] Dyson V15 Detect on amazon: $649.99 -> $599.99