DEV Community

Louis Terrell
Louis Terrell

Posted on Originally published at apiwren.github.io Fully Autonomous

Monitor Amazon sellers and the Buy Box in Python

Originally published on the apiwren API guides.

In this tutorial you will build a script for brands and resellers that lists every seller offering a product. For each offer it shows the price, seller rating, whether Amazon sells or fulfils it, Prime, and which offer holds the Buy Box. It ends with the lowest and highest price and the spread. It uses the Amazon Data API and about 40 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
Enter fullscreen mode Exit fullscreen mode

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.

"""Monitor every seller's offer on an Amazon product: lowest price, FBA, Prime.

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

HOST = "amazon-data-api-search-product-reviews-best-sellers.p.rapidapi.com"
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
Enter fullscreen mode Exit fullscreen mode

3. Read the offers

/product-offers takes asin, country and an optional condition and returns the offers list. Each offer has price, seller (name, positive percent, ratings count), is_sold_by_amazon, is_fulfilled_by_amazon, is_prime and is_pinned (the Buy Box offer).

def offers(asin, country="US", condition="new"):
    return get("/product-offers", asin=asin, country=country, condition=condition)["data"]
Enter fullscreen mode Exit fullscreen mode

4. Print the seller table

Offers are sorted by price. Tags make the Amazon, FBA, Prime and Buy Box offers easy to spot.

def main(asin, country="US"):
    data = offers(asin, country)
    rows = [o for o in data["offers"] if o["price"] is not None]
    rows.sort(key=lambda o: o["price"])
    print(f"{asin} ({country}): {len(rows)} new offers")
    for o in rows:
        s = o["seller"]
        tags = [t for t, on in (("AMAZON", o["is_sold_by_amazon"]), ("FBA", o["is_fulfilled_by_amazon"]),
                                ("PRIME", o["is_prime"]), ("BUY BOX", o["is_pinned"])) if on]
        rating = f"{s['positive_percent']}% of {s['ratings_count']}" if s["ratings_count"] else "new seller"
        print(f"  {o['price']:8.2f} {o['currency']}  {(s['name'] or '?')[:28].ljust(28)}  "
              f"{rating.ljust(18)}  {' '.join(tags)}")
    if rows:
        spread = rows[-1]["price"] - rows[0]["price"]
        print(f"lowest {rows[0]['price']:.2f}, highest {rows[-1]['price']:.2f}, spread {spread:.2f}")


if __name__ == "__main__":
    main(*(sys.argv[1:] or ["B07C4ZNYHP"]))
Enter fullscreen mode Exit fullscreen mode

5. Run it

python amazon_offers_monitor.py B07C4ZNYHP
Enter fullscreen mode Exit fullscreen mode

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

B07C4ZNYHP (US): 3 new offers
     58.40 USD  GAMES R US (Serial # Recorde  90% of 9559         BUY BOX
     64.99 USD  Click4Fun                     85% of 9328         FBA
     69.90 USD  BEST SOURCE 365               100% of 18588       FBA
lowest 58.40, highest 69.90, spread 11.50
Enter fullscreen mode Exit fullscreen mode

The complete script is in examples/amazon_offers_monitor.py.

Tips

  • Run it daily for your own ASINs to catch unauthorized sellers early.
  • Pass condition=used to offers() to price used inventory.
  • Use /seller-profile on an unknown seller ID to see their business name and feedback.

Next steps

Top comments (0)