Walmart is a critical data source for price intelligence, competitive analysis, and retail arbitrage. Direct scraping of Walmart is blocked aggressively with bot detection, JavaScript challenges, and IP bans. The Scavio API provides a stable Walmart product search endpoint that returns structured JSON including title, price, rating, review count, seller name, availability, and product URL. This tutorial shows how to search for products, handle pagination, filter by seller, and export the data for analysis.
Prerequisites
- Python 3.8 or higher
- requests library installed
- A Scavio API key
- Product categories or specific queries to search
Walkthrough
Step 1: Search Walmart for products
POST to the Scavio endpoint with platform walmart and your search query. The products array contains structured listings.
def search_walmart(query: str) -> list[dict]:
r = requests.post(
"https://api.scavio.dev/api/v1/search",
headers={"x-api-key": API_KEY},
json={"platform": "walmart", "query": query}
)
r.raise_for_status()
return r.json().get("products", [])Step 2: Extract and normalize product data
Parse each product result into a clean dictionary with consistent types for downstream processing.
def normalize_product(product: dict) -> dict:
price_str = product.get("price", "")
return {
"title": product.get("title", ""),
"price": float(price_str.replace("$", "").replace(",", "")) if price_str else None,
"rating": float(product.get("rating", 0) or 0),
"reviews": int(product.get("reviews_count", 0) or 0),
"seller": product.get("seller", ""),
"availability": product.get("availability", ""),
"url": product.get("url", ""),
}Step 3: Filter by seller or price range
Apply filters to narrow results to specific sellers or price bands.
def filter_products(products: list[dict], max_price: float = None, seller: str = None) -> list[dict]:
filtered = products
if max_price:
filtered = [p for p in filtered if p["price"] and p["price"] <= max_price]
if seller:
filtered = [p for p in filtered if seller.lower() in p["seller"].lower()]
return filteredStep 4: Export to JSON for analysis
Write the normalized product data to a JSON file with summary statistics.
import json
def export_products(query: str, products: list[dict]) -> None:
prices = [p["price"] for p in products if p["price"]]
output = {
"query": query,
"total": len(products),
"price_range": {"min": min(prices), "max": max(prices)} if prices else {},
"products": products,
}
with open("walmart_products.json", "w") as f:
json.dump(output, f, indent=2)Python Example
import os
import json
import requests
API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"
def search_walmart(query: str) -> list[dict]:
r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY},
json={"platform": "walmart", "query": query})
r.raise_for_status()
return r.json().get("products", [])
def normalize(p: dict) -> dict:
price = p.get("price", "")
return {
"title": p.get("title"), "price": float(price.replace("$", "").replace(",", "")) if price else None,
"rating": p.get("rating"), "seller": p.get("seller"), "url": p.get("url")
}
if __name__ == "__main__":
raw = search_walmart("robot vacuum")
products = [normalize(p) for p in raw]
products.sort(key=lambda x: x["price"] or float("inf"))
for p in products[:5]:
print(f"${p['price']:.2f} | {p['rating']} stars | {p['title'][:50]}")
print(f"\nTotal: {len(products)} products")JavaScript Example
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";
async function searchWalmart(query) {
const res = await fetch(ENDPOINT, {
method: "POST",
headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ platform: "walmart", query })
});
const data = await res.json();
return (data.products || []).map(p => ({
title: p.title, price: p.price ? parseFloat(p.price.replace(/[$,]/g, "")) : null,
rating: p.rating, seller: p.seller, url: p.url
}));
}
async function main() {
const products = await searchWalmart("robot vacuum");
products.sort((a, b) => (a.price || Infinity) - (b.price || Infinity))
.slice(0, 5).forEach(p => console.log(`$${p.price} | ${p.rating} stars | ${p.title?.slice(0, 50)}`));
}
main().catch(console.error);Expected Output
{
"products": [
{
"title": "Shark ION Robot Vacuum RV720",
"price": "$149.00",
"rating": "4.3",
"reviews_count": 8742,
"seller": "Walmart.com",
"availability": "In Stock",
"url": "https://walmart.com/ip/shark-ion-robot/..."
}
]
}
$149.00 | 4.3 stars | Shark ION Robot Vacuum RV720
$179.00 | 4.5 stars | iRobot Roomba 694 Robot Vacuum
$199.99 | 4.6 stars | Roborock Q5 Robot Vacuum