ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Add Walmart Price Tracking to an Agent
Tutorial

How to Add Walmart Price Tracking to an Agent

Track Walmart product prices daily using the Scavio search API with platform:walmart. Store prices in SQLite and alert on price drops over 10%.

Get Free API KeyAPI Docs

You can track Walmart product prices without scraping by searching with platform set to walmart in the Scavio API. The response returns structured product listings with current prices, which you store daily and diff for alerts.

Prerequisites

  • Python 3.9+
  • Scavio API key
  • SQLite (stdlib)

Walkthrough

Step 1: Search Walmart for a product

Set platform:walmart to get Walmart product listings with structured price data.

Python
import requests

API_KEY = "your-scavio-api-key"

def search_walmart(query: str, num_results: int = 10) -> list:
    r = requests.post(
        "https://api.scavio.dev/api/v1/search",
        json={"query": query, "platform": "walmart", "num_results": num_results},
        headers={"x-api-key": API_KEY},
        timeout=20
    )
    r.raise_for_status()
    return r.json().get("organic_results", [])

products = search_walmart("Sony WH-1000XM5 headphones")
for p in products:
    print(p.get("title"), p.get("price"))

Step 2: Track prices in SQLite

Store the product title, price, and date for each tracked item.

Python
import sqlite3, re
from datetime import date

def init_db(path="walmart_tracker.db"):
    conn = sqlite3.connect(path)
    conn.execute("""
        CREATE TABLE IF NOT EXISTS prices (
            date TEXT, query TEXT, title TEXT, price_raw TEXT, price_usd REAL,
            url TEXT, PRIMARY KEY (date, url)
        )
    """)
    conn.commit()
    return conn

def parse_price(s: str) -> float:
    m = re.search(r"[\d.]+", (s or "").replace(",",""))
    return float(m.group()) if m else 0.0

def store(conn, query, product):
    conn.execute("INSERT OR REPLACE INTO prices VALUES (?,?,?,?,?,?)",
        (str(date.today()), query, product.get("title"),
         product.get("price"), parse_price(product.get("price","")),
         product.get("link","")))
    conn.commit()

Step 3: Alert on price drops

Compare today's price with the previous day's price. Alert if drop exceeds threshold.

Python
def check_alerts(conn, url: str, threshold_pct: float = 10.0) -> dict | None:
    rows = conn.execute(
        "SELECT date, price_usd, title FROM prices WHERE url=? ORDER BY date DESC LIMIT 2",
        (url,)
    ).fetchall()
    if len(rows) < 2:
        return None
    today_price = rows[0][1]
    prev_price = rows[1][1]
    if prev_price == 0:
        return None
    drop_pct = (prev_price - today_price) / prev_price * 100
    if drop_pct >= threshold_pct:
        return {
            "title": rows[0][2],
            "prev_price": prev_price,
            "today_price": today_price,
            "drop_pct": round(drop_pct, 1),
            "url": url
        }
    return None

Python Example

Python
import requests
import sqlite3
import re
from datetime import date

API_KEY = "your-scavio-api-key"
TRACKED = [
    "Sony WH-1000XM5 headphones",
    "iPad Air 2026",
    "Instant Pot Duo 7-in-1"
]

def search_walmart(query, n=5):
    r = requests.post("https://api.scavio.dev/api/v1/search",
                      json={"query": query, "platform": "walmart", "num_results": n},
                      headers={"x-api-key": API_KEY}, timeout=20)
    r.raise_for_status()
    return r.json().get("organic_results", [])

def parse_price(s):
    m = re.search(r"[\d.]+", (s or "").replace(",",""))
    return float(m.group()) if m else 0.0

def init_db(path="walmart_tracker.db"):
    conn = sqlite3.connect(path)
    conn.execute("CREATE TABLE IF NOT EXISTS prices (date TEXT, query TEXT, title TEXT, price_raw TEXT, price_usd REAL, url TEXT, PRIMARY KEY (date, url))")
    conn.commit()
    return conn

def run_tracker():
    conn = init_db()
    alerts = []
    today = str(date.today())
    for query in TRACKED:
        products = search_walmart(query, n=3)
        for p in products:
            url = p.get("link","")
            price_usd = parse_price(p.get("price",""))
            conn.execute("INSERT OR REPLACE INTO prices VALUES (?,?,?,?,?,?)",
                         (today, query, p.get("title"), p.get("price"), price_usd, url))
            conn.commit()
            # Check alert
            rows = conn.execute("SELECT date, price_usd FROM prices WHERE url=? ORDER BY date DESC LIMIT 2", (url,)).fetchall()
            if len(rows) == 2 and rows[1][1] > 0:
                drop = (rows[1][1] - rows[0][1]) / rows[1][1] * 100
                if drop >= 10:
                    alerts.append({"title": p.get("title"), "drop_pct": round(drop,1),
                                   "prev": rows[1][1], "now": rows[0][1]})
        print(f"Tracked: {query} ({len(products)} products)")
    if alerts:
        print("\nPRICE DROP ALERTS:")
        for a in alerts:
            print(f"  {a['title'][:50]} | ${a['prev']} -> ${a['now']} (-{a['drop_pct']}%)")
    else:
        print("\nNo significant price drops today.")

if __name__ == "__main__":
    run_tracker()

JavaScript Example

JavaScript
const API_KEY = 'your-scavio-api-key';

async function searchWalmart(query, n = 5) {
  const res = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'x-api-key': API_KEY },
    body: JSON.stringify({ query, platform: 'walmart', num_results: n })
  });
  const data = await res.json();
  return data.organic_results ?? [];
}

const products = await searchWalmart('Sony WH-1000XM5 headphones');
for (const p of products.slice(0, 3)) {
  console.log(`${p.title?.slice(0, 60)} | ${p.price}`);
}

Expected Output

JSON
Tracked: Sony WH-1000XM5 headphones (3 products)
Tracked: iPad Air 2026 (3 products)
Tracked: Instant Pot Duo 7-in-1 (3 products)

PRICE DROP ALERTS:
  Sony WH-1000XM5 Wireless Headphones (Black) | $349.00 -> $279.00 (-20.1%)

Related Tutorials

  • How to Build an Amazon Price Alert Agent
  • How to Get Amazon Product Data Without Scraping
  • How to Monitor Competitor SERP Positions with an API

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.9+. Scavio API key. SQLite (stdlib). A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, 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 E-Commerce Price Tracking API in 2026

Read more
Best Of

Best API for Cross-Platform Price Monitoring in 2026

Read more
Workflow

Walmart Price and Availability Alert Workflow

Read more
Use Case

Walmart Search API for Product Intelligence

Read more
Use Case

Walmart Seller Product Intelligence

Read more
Glossary

Walmart Product Data API Landscape (2026)

Read more

Start Building

Track Walmart product prices daily using the Scavio search API with platform:walmart. Store prices in SQLite and alert on price drops over 10%.

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