Skip to the content.

Build an Amazon price-drop alert in Python

In this tutorial you will build a price watcher for Amazon. You list ASINs with a marketplace and a target price. Each run reads the current price and saves it. It flags a DROP when the price fell since the last run, and TARGET when it is at or below your target. It uses the Amazon Data API and about 55 lines of Python.

What you need: Python 3.8+, pip install requests, and a free RapidAPI key.

1. Subscribe to the free plan

  1. Open the Amazon Data API on RapidAPI and subscribe to the free Basic plan (20 requests a month).
  2. Copy your X-RapidAPI-Key and export it:
export RAPIDAPI_KEY=your_key

2. A small helper to call the API

The helper sends your key, retries rate limits (HTTP 429) and server errors (5xx) with a growing wait, and stops with the API’s error message on anything else.

"""Alert when Amazon products drop in price or hit your target price.

Uses the Amazon Data API on RapidAPI:
https://rapidapi.com/apiwren-apiwren-default/api/amazon-data-api-search-product-reviews-best-sellers
"""
import json, os, sys, time
import requests

HOST = "amazon-data-api-search-product-reviews-best-sellers.p.rapidapi.com"
STATE = "amazon_prices.json"
HEADERS = {"X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"], "X-RapidAPI-Host": HOST}


def get(path, **params):
    """GET one endpoint. Retries rate limits (429) and server errors (5xx)."""
    for attempt in range(4):
        r = requests.get(f"https://{HOST}{path}", headers=HEADERS, params=params, timeout=90)
        retry = r.status_code == 429 or r.status_code in range(500, 600)
        if retry and attempt != 3:
            time.sleep(float(r.headers.get("Retry-After") or 2 ** (attempt + 1)))
            continue
        if not r.ok:
            sys.exit(f"HTTP {r.status_code}: {r.text[:300]}")
        body = r.json()
        if isinstance(body, dict) and body.get("success") is False:
            sys.exit(f"API error: {body.get('error')}")
        return body

3. List the products to watch

Each entry is an ASIN, a marketplace code and a target price. The ASIN is the 10-character code after /dp/ in an Amazon URL.

# ASIN, marketplace, alert when the price is at or below this target
WATCHLIST = [
    ("B088NRLMPV", "US", 9.00),
    ("B0BSHF7WHW", "US", 199.00),
    ("B07DC5PPFV", "GB", 6.00),
]

4. Check the price

/product-details takes asin and country and returns price, currency, availability, title and much more. price is null when the product is unavailable, so the script reports that instead of a price.

def check(asin, country, target, last):
    d = get("/product-details", asin=asin, country=country)["data"]
    price = d["price"]
    if price is None:
        return None, f"{asin}  unavailable ({d['availability']})  {d['title'][:50]}"
    flags = []
    if last is not None and price != last and price == min(price, last):
        flags.append(f"DROP from {last}")
    if price == min(price, target):
        flags.append(f"TARGET {target} reached")
    line = f"{asin}  {price:8.2f} {d['currency']}  {', '.join(flags) or 'no alert'}  {d['title'][:50]}"
    return price, line


def main():
    try:
        state = json.load(open(STATE))
    except FileNotFoundError:
        state = {}
    for asin, country, target in WATCHLIST:
        key = f"{country}:{asin}"
        price, line = check(asin, country, target, state.get(key))
        print(line)
        if price is not None:
            state[key] = price
    json.dump(state, open(STATE, "w"), indent=2)


if __name__ == "__main__":
    main()

5. Run it

python amazon_price_drop_alert.py

Real output from a run on 2026-11-28:

B088NRLMPV      7.99 USD  TARGET 9.0 reached  Anker USB C to USB C Cable, 60W Fast Charging Cabl
B0BSHF7WHW  unavailable (Currently unavailable.)  Apple 2023 MacBook Pro Laptop with Apple M2 Pro ch
B07DC5PPFV      6.63 GBP  no alert  Anker USB C Charger Cable, 2-Pack 6 ft (1.8 m) USB

The complete script is in examples/amazon_price_drop_alert.py.

Tips

Next steps