DEV Community

Aurelix Solutions
Aurelix Solutions

Posted on

Amazon product details by ASIN in Python: price, buy box, stock and variants, no login

Sellers, brands and repricers keep a list of ASINs they care about: their own listings, the competing ones, the variants of a best seller. Each day the question is the same: what does it cost now, who holds the buy box, is it in stock, and did anything move since yesterday. Opening each product page by hand stops working after a dozen ASINs.

This post reads Amazon product pages into Python from a list of ASINs, compares prices and buy-box sellers, lists every variant, and sets up a daily feed of only the products that changed.

Disclosure: I'm Aurelix, and I built Amazon Product Details Scraper, the tool used here. It's a paid tool (prices below).

What each row holds

39 fields per product:

  • asin, url, marketplace, title, brand.
  • price, priceText, listPrice with Amazon's own label in listPriceLabel (List Price, Was, RRP or Typical price), savingsPercent, currency.
  • buyBoxSeller, buyBoxSellerId, shipsFrom, buyBoxPrice, availability, inStock, deliverTo.
  • rating, reviewCount, and on Amazon's full product page ratingHistogram, bestSellersRank and description.
  • bullets, images, dealBadge, coupon, badges.
  • parentAsin, variationDimensions, variantCount, variants (every variant ASIN with its size, color or style).
  • fullPage: true when Amazon served its full product page. Amazon often serves its compact page instead, which has no rank, histogram or description; those fields are then empty, never guessed.

Products from a list of ASINs

pip install apify-client
Enter fullscreen mode Exit fullscreen mode
import csv
import os

from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("aurelix/amazon-product-details-scraper").call(
    run_input={
        "products": [
            "B005EPRFKO",
            "https://www.amazon.com/dp/B07Z8G97PY",
            "https://www.amazon.ca/dp/B005EPRFKO",
        ],
    }
)
products = [p for p in client.dataset(run["defaultDatasetId"]).iterate_items() if not p.get("error_code")]

fields = ["asin", "marketplace", "title", "price", "listPrice", "buyBoxSeller", "inStock", "rating", "reviewCount"]
with open("products.csv", "w", newline="", encoding="utf-8") as f:
    w = csv.DictWriter(f, fieldnames=fields, extrasaction="ignore")
    w.writeheader()
    w.writerows(products)
Enter fullscreen mode Exit fullscreen mode

Bare ASINs use the marketplace input (amazon.com by default); full links keep their own marketplace. An ASIN Amazon has no page for returns a row with error_code not_found.

Who holds the buy box, and how far below list price

for p in sorted(products, key=lambda p: -(p["savingsPercent"] or 0)):
    print(f"{p['asin']} {p['marketplace']:14} {p['priceText'] or '-':>9}  "
          f"{p['listPriceLabel'] or '':13} -{p['savingsPercent'] or 0}%  {p['buyBoxSeller'] or 'no buy box'}")
Enter fullscreen mode Exit fullscreen mode

Every variant of a product

Each row lists all variant ASINs the page knows, with their attributes, at no extra charge. To read each variant's own price and stock, turn on includeVariants (each variant read is a product row, capped by maxVariantsPerProduct):

run_input = {"products": ["B005EPRFKO"], "includeVariants": True, "maxVariantsPerProduct": 20}
Enter fullscreen mode Exit fullscreen mode

Only what changed, every morning

run_input = {
    "products": ["B005EPRFKO", "B07Z8G97PY"],
    "onlyChanges": True,
    "stateKey": "competitors-daily",
    "slackWebhookUrl": "https://hooks.slack.com/services/...",
}
Enter fullscreen mode Exit fullscreen mode

The first run returns every product and saves it as a baseline. Each later run returns only products whose price, buy box, stock or top Best Sellers Rank moved, with changedFields and the previous values; unchanged products are not returned and cost a small check fee instead. Keep stateKey set so the memory stays the same while you add or remove ASINs. Save the input as a task in the Apify Console and schedule it daily: Slack gets a short digest, and nothing is sent when nothing changed.

Why this tool

  • Price, list price with its label, buy-box seller and seller ID on every row.
  • Every variant ASIN listed, and each variant readable as its own row.
  • A change monitor for price, buy box, stock and rank, with the previous values.
  • One flat price per product row, whatever the page holds.

Limits

  • amazon.com, amazon.ca, amazon.co.uk and amazon.de only.
  • Best Sellers Rank, the rating histogram and the description are only on Amazon's full product page. Many reads get its compact page without them; the optional 'Always full pages' add-on reads every product's full page over residential IPs, at an extra fee per request.
  • amazon.co.uk and amazon.de are read only over UK and German residential IPs, so prices include VAT; that needs 'Residential fallback' or 'Always full pages', at an extra fee per residential request. Without it, those products get a free row saying so. deliverTo shows the delivery location on every row.
  • Products Amazon refuses on every attempt are named in the run status and not charged. No reviews or other sellers' offers.

Cost

$1.50 per 1,000 products on Apify's free plan, from $1.10 per 1,000 on paid plans, plus a small start fee per run; optional add-ons cost extra only when you switch them on. The current prices are on the Store page; Apify's free plan includes $5 of credit a month, about 3,300 products.

Use it from an AI assistant

The tool also works through Apify's hosted MCP server, so Claude, ChatGPT or Cursor can run it from a request like "get the price, buy-box seller and stock of these 20 ASINs on amazon.com". Server URL: https://mcp.apify.com/?tools=aurelix/amazon-product-details-scraper.

Links

Top comments (0)