ScavioScavio
FeaturesPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Compare Prices Across Amazon and Walmart via API
Tutorial

How to Compare Prices Across Amazon and Walmart via API

Build an automated price comparison tool that queries Amazon and Walmart simultaneously via the Scavio API. Find the best price for any product across platforms.

Get Free API KeyAPI Docs

Price comparison across Amazon and Walmart helps shoppers save money and helps sellers identify pricing opportunities. Querying both platforms manually is slow and the data goes stale quickly. This tutorial builds an automated price comparison tool using the Scavio API that searches both Amazon and Walmart for the same product, normalizes prices, matches similar items across platforms, and outputs a side-by-side comparison showing which platform offers the better deal.

Prerequisites

  • Python 3.10 or higher
  • requests library installed
  • A Scavio API key
  • Products to compare across platforms

Walkthrough

Step 1: Query both platforms concurrently

Search Amazon and Walmart for the same product query simultaneously to minimize latency.

Python
from concurrent.futures import ThreadPoolExecutor

def search_platform(platform: str, query: str) -> list[dict]:
    r = requests.post(
        "https://api.scavio.dev/api/v1/search",
        headers={"x-api-key": API_KEY},
        json={"platform": platform, "query": query, "marketplace": "US"}
    )
    r.raise_for_status()
    return r.json().get("products", [])

def compare(query: str) -> dict:
    with ThreadPoolExecutor(max_workers=2) as ex:
        a_fut = ex.submit(search_platform, "amazon", query)
        w_fut = ex.submit(search_platform, "walmart", query)
        return {"amazon": a_fut.result(), "walmart": w_fut.result()}

Step 2: Parse and normalize prices

Extract prices from both platforms and convert to float values for comparison.

Python
def parse_price(price_str: str) -> float | None:
    if not price_str:
        return None
    return float(price_str.replace("$", "").replace(",", ""))

def normalize_product(product: dict, platform: str) -> dict:
    return {
        "platform": platform,
        "title": product.get("title", ""),
        "price": parse_price(product.get("price", "")),
        "price_raw": product.get("price", ""),
        "rating": product.get("rating"),
        "url": product.get("url", product.get("link", "")),
    }

Step 3: Find the best price across platforms

Merge normalized results from both platforms and sort by price to find the best deal.

Python
def best_deals(query: str, top_n: int = 10) -> list[dict]:
    data = compare(query)
    items = []
    for p in data["amazon"][:10]:
        items.append(normalize_product(p, "amazon"))
    for p in data["walmart"][:10]:
        items.append(normalize_product(p, "walmart"))
    return sorted(items, key=lambda x: x["price"] or float("inf"))[:top_n]

Step 4: Output comparison table

Print a formatted comparison table showing the best prices from each platform.

Python
def print_comparison(query: str) -> None:
    deals = best_deals(query)
    print(f"Price comparison: {query}\n" + "-" * 60)
    print(f"{'Platform':<10} {'Price':<10} {'Rating':<8} {'Title'}")
    for d in deals:
        price = f"${d['price']:.2f}" if d['price'] else 'N/A'
        print(f"{d['platform']:<10} {price:<10} {d['rating'] or 'N/A':<8} {d['title'][:40]}")

Python Example

Python
import os
import requests
from concurrent.futures import ThreadPoolExecutor

API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"

def search(platform: str, query: str) -> list[dict]:
    r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY},
                      json={"platform": platform, "query": query, "marketplace": "US"})
    r.raise_for_status()
    return r.json().get("products", [])

def compare(query: str) -> None:
    with ThreadPoolExecutor(max_workers=2) as ex:
        a = ex.submit(search, "amazon", query)
        w = ex.submit(search, "walmart", query)
    items = []
    for p in a.result()[:5]:
        price = float(p.get("price", "0").replace("$", "").replace(",", "") or 0)
        items.append({"src": "amazon", "price": price, "title": p.get("title", ""), "rating": p.get("rating")})
    for p in w.result()[:5]:
        price = float(p.get("price", "0").replace("$", "").replace(",", "") or 0)
        items.append({"src": "walmart", "price": price, "title": p.get("title", ""), "rating": p.get("rating")})
    items.sort(key=lambda x: x["price"] or float("inf"))
    print(f"{'Source':<10} {'Price':<10} {'Rating':<8} {'Title'}")
    for i in items:
        print(f"{i['src']:<10} ${i['price']:<9.2f} {i['rating'] or 'N/A':<8} {i['title'][:40]}")

if __name__ == "__main__":
    compare("AirPods Pro")

JavaScript Example

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";

async function search(platform, query) {
  const res = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ platform, query, marketplace: "US" })
  });
  const data = await res.json();
  return (data.products || []).slice(0, 5).map(p => ({
    src: platform,
    title: p.title,
    price: p.price ? parseFloat(p.price.replace(/[$,]/g, "")) : null,
    rating: p.rating
  }));
}

async function compare(query) {
  const [amazon, walmart] = await Promise.all([
    search("amazon", query), search("walmart", query)
  ]);
  const all = [...amazon, ...walmart].sort((a, b) => (a.price || Infinity) - (b.price || Infinity));
  console.log(`Price comparison: ${query}`);
  all.forEach(i => console.log(`${i.src.padEnd(10)} $${i.price?.toFixed(2) || 'N/A'.padEnd(9)} ${i.title?.slice(0, 40)}`));
}

compare("AirPods Pro").catch(console.error);

Expected Output

JSON
Source     Price      Rating   Title
amazon     $189.00    4.7      Apple AirPods Pro (2nd Generation)
walmart    $189.00    4.7      Apple AirPods Pro 2nd Gen with USB-C
amazon     $199.99    4.6      Apple AirPods Pro with MagSafe Case
walmart    $199.00    4.5      Apple AirPods Pro 2 Wireless Earbuds
amazon     $234.99    4.8      Apple AirPods Pro Premium Bundle

Related Tutorials

  • How to Build a Price Comparison Tool for Amazon and Walmart
  • How to Get Walmart Product Data via API in Structured JSON

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.10 or higher. requests library installed. A Scavio API key. Products to compare across platforms. 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.

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
Use Case

Cross-Platform Price Monitoring

Read more
Use Case

Walmart Seller Product Intelligence

Read more
Solution

Cross-Platform Intelligence from One API Endpoint

Read more
Solution

Track Prices Across Amazon, Walmart, and Google Shopping

Read more

Start Building

Build an automated price comparison tool that queries Amazon and Walmart simultaneously via the Scavio API. Find the best price for any product across platforms.

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