ScavioScavio
FeaturesPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Build a Deal Finder with Price Monitoring and Alerts
Tutorial

How to Build a Deal Finder with Price Monitoring and Alerts

Build a deal finder in Python that monitors Amazon and Walmart prices, calculates discount percentage, and sends alerts when deals exceed a threshold.

Get Free API KeyAPI Docs

Deal finding applications watch product prices across retailers and notify users when prices drop significantly. The key metrics are the current price versus the original or historical price, expressed as a discount percentage. Amazon and Walmart product responses from the Scavio API include both current and original prices when available, making it straightforward to compute discounts on the fly. This tutorial builds a deal finder that scans product search results, calculates discounts, and outputs deals above a configurable threshold.

Prerequisites

  • Python 3.8 or higher
  • requests library installed
  • A Scavio API key
  • Basic Python math and string parsing

Walkthrough

Step 1: Search for products and extract prices

Query Amazon for a product category and extract both current price and original price for each result.

Python
def extract_prices(product: dict) -> tuple[float | None, float | None]:
    def parse(s):
        return float(s.replace("$", "").replace(",", "")) if s else None
    return parse(product.get("price")), parse(product.get("original_price"))

Step 2: Calculate discount percentage

Compute the discount percentage from current and original price. Return 0 if original price is unavailable.

Python
def discount_pct(current: float | None, original: float | None) -> float:
    if not current or not original or original <= current:
        return 0.0
    return round((original - current) / original * 100, 1)

Step 3: Filter deals above a threshold

Scan all products and return those with a discount percentage at or above the configured threshold.

Python
def find_deals(products: list[dict], min_discount: float = 20.0) -> list[dict]:
    deals = []
    for p in products:
        current, original = extract_prices(p)
        pct = discount_pct(current, original)
        if pct >= min_discount:
            deals.append({**p, "discount_pct": pct})
    return sorted(deals, key=lambda x: x["discount_pct"], reverse=True)

Step 4: Print deal alerts

Output a formatted deal alert for each qualifying product.

Python
def print_deals(deals: list[dict]) -> None:
    if not deals:
        print("No deals found above threshold")
        return
    for d in deals:
        print(f"[{d['discount_pct']}% OFF] {d['title'][:50]}")
        print(f"  Now: {d.get('price')} | Was: {d.get('original_price')}")

Python Example

Python
import os
import requests

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

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

def parse_price(s): return float(s.replace("$", "").replace(",", "")) if s else None

def find_deals(products, min_pct=20):
    deals = []
    for p in products:
        curr = parse_price(p.get("price"))
        orig = parse_price(p.get("original_price"))
        if curr and orig and orig > curr:
            pct = round((orig - curr) / orig * 100, 1)
            if pct >= min_pct:
                deals.append({**p, "pct": pct})
    return sorted(deals, key=lambda x: x["pct"], reverse=True)

if __name__ == "__main__":
    products = search_amazon("bluetooth headphones")
    for deal in find_deals(products):
        print(f"[{deal['pct']}% off] {deal.get('title', '')[:50]} — {deal.get('price')}")

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 searchAmazon(query) {
  const res = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ platform: "amazon", query, marketplace: "US" })
  });
  const data = await res.json();
  return data.products || [];
}

function parsePrice(s) { return s ? parseFloat(s.replace(/[$,]/g, "")) : null; }

function findDeals(products, minPct = 20) {
  return products
    .map(p => ({ ...p, pct: (() => {
      const curr = parsePrice(p.price), orig = parsePrice(p.original_price);
      return curr && orig && orig > curr ? Math.round((orig - curr) / orig * 1000) / 10 : 0;
    })() }))
    .filter(p => p.pct >= minPct)
    .sort((a, b) => b.pct - a.pct);
}

searchAmazon("bluetooth headphones").then(products => {
  findDeals(products).forEach(d => console.log(`[${d.pct}% off] ${d.title?.slice(0, 50)} — ${d.price}`));
}).catch(console.error);

Expected Output

JSON
[45% off] Beats Studio3 Wireless Headphones
  Now: $109.99 | Was: $199.99

[30% off] Sony WH-CH520 Wireless Headphones
  Now: $34.99 | Was: $49.99

[25% off] JBL Tune 510BT Wireless On-Ear
  Now: $29.99 | Was: $39.99

Related Tutorials

  • How to Monitor Amazon Prices Across Multiple ASINs
  • How to Build a Price Comparison Tool for Amazon and Walmart

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. Basic Python math and string parsing. 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 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
Glossary

Search API Provider Landscape (2026)

Read more
Solution

Get Alerted When Product Prices Change on Amazon and Walmart

Read more
Use Case

Multi-Platform Price Tracking

Read more

Start Building

Build a deal finder in Python that monitors Amazon and Walmart prices, calculates discount percentage, and sends alerts when deals exceed a threshold.

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