Tutorial

How to Get Walmart Product Data via API in Structured JSON

Fetch Walmart product listings with prices, ratings, seller info, and availability in structured JSON using the Scavio API. No scraping infrastructure needed.

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.

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

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

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

Step 4: Export to JSON for analysis

Write the normalized product data to a JSON file with summary statistics.

Python
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

Python
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

JavaScript
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

JSON
{
  "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

Related Tutorials

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 or higher. requests library installed. A Scavio API key. Product categories or specific queries to search. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 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.

Start Building

Fetch Walmart product listings with prices, ratings, seller info, and availability in structured JSON using the Scavio API. No scraping infrastructure needed.