Home / Blog / Amazon Price Tracker in a Notion Database via the API

Amazon Price Tracker in a Notion Database via the API

A Python script that reads the Buy Box price for a watchlist of ASINs from the SellerMagnet API and keeps it current in a Notion database: one query to find each ASIN's existing page, one update or one new page per ASIN, and a price that clears to empty instead of 0 when nothing is on offer.

November 19, 2026
5 min read
SellerMagnet Team
Share & Bookmark
Terminal running a Python script that syncs Amazon Buy Box prices into a Notion database

A watchlist of ASINs and a Notion database are a natural fit: everyone on the team already has Notion open, and a database view sorts, filters and groups the rows for free. This script reads the Buy Box price from /api/amazon-product-offers (1 credit per ASIN) and upserts it into a Notion data source: an existing row gets Price, Currency and Checked patched, a new ASIN gets a new page. No automation platform in between, just the Notion REST API and Python.

Key Takeaways

  • One /amazon-product-offers call per ASIN (1 credit); the Notion write costs no SellerMagnet credits, only Notion's own request budget.
  • Notion's own rate limit is an average of 3 requests per second per connection on most plans (10/s on Business/Enterprise); the script sleeps between calls and retries once on a 429.
  • A missing Buy Box clears the Notion Price property to null, never 0, so a real free item and 'nothing on offer' never look the same in the database.
  • Existing rows are found once per run via a data source query, paginated with has_more and next_cursor, not one Notion search call per tracked ASIN.
  • A 401 or 403 stops the whole run before any later ASIN is touched, the same billing-safe pattern as the Slack and Discord alert posts.

Setting up the Notion side

Create an internal integration at notion.so/my-integrations, copy its token, then share your database with that integration from the database's ••• menu (Notion's own permission model: an unshared database answers every API call with a 404, not a 403). The database needs four properties with these exact types; the script writes to all four and reads the title to match an ASIN to its existing page.

Notion database properties this script reads and writes.
PropertyNotion typeWhy
ASINtitleThe page's title; also the lookup key this script uses to find an existing row
Pricenumbernull clears a stale price on 'no featured offer', never 0
Currencyrich_textAn empty array (never a blank string) when there is no price to report
CheckeddateISO 8601 UTC timestamp of this run, written on every sync
Table of the four Notion properties this script writes, their type and why each one matters
Price is a number (sorts and filters), Currency a rich_text, Checked a date.

Read the Buy Box price and currency for one ASIN with curl and jq

# One offers call (1 credit): the Buy Box price and currency this script writes to Notion
curl -sG "https://sellermagnet-api.com/api/amazon-product-offers" \
  -H "X-Api-Key: $SELLERMAGNET_API_KEY" \
  --data-urlencode "asin=B0CL61F39H" --data-urlencode "marketplaceId=ATVPDKIKX0DER" \
  | jq '.data | {price: .buyBox.totalPrice, currency: .currency.code}' 

Respecting Notion's rate limit

Notion enforces a per-connection limit measured over a 60 second window, separate from any SellerMagnet rate limit. A request over the limit answers 429 with a Retry-After header; the JavaScript SDK waits and retries automatically, this script does the same by hand since it only uses requests.

Notion's per-connection request limit (developers.notion.com, checked live).
PlanLimitScope
Business / Enterprise plan600 requests / 60 s window (about 10/s)per connection
Every other plan180 requests / 60 s window (about 3/s)per connection
Over the limitHTTP 429 with a Retry-After headerwait exactly that long, then retry once

notion_price_tracker.py: find-or-create a Notion page per ASIN, patch its price

"""Sync Amazon Buy Box prices into a Notion database (data source) via the Notion API.

One /amazon-product-offers call per ASIN (1 credit). Notion's average rate limit is 3 requests
per second per connection (developers.notion.com/reference/request-limits), so this script sleeps
between Notion calls and honours a 429's Retry-After header instead of hammering it. The data
source is queried once per run to find each ASIN's existing page by its title property; a missing
ASIN gets a new page, an existing one gets its Price/Currency/Checked properties patched.
Helpers: sellermagnet.py and retry.py from the Python quickstart post.
"""
import os
import re
import time

import requests

from retry import get_with_retry
from sellermagnet import ApiError, new_session

ASIN_RE = re.compile(r"^[A-Z0-9]{10}$")  # offers calls are billed even for a typo, so filter first
MARKETPLACE = "ATVPDKIKX0DER"           # amazon.com
ASINS = ["B0CL61F39H", "B0EXAMPLE1", "B0EXAMPLE2", "B0EXAMPLE3"]
NOTION_API = "https://api.notion.com/v1"
NOTION_VERSION = "2025-09-03"           # pin a version; this script was written against this one
NOTION_RATE_DELAY = 0.4                 # keeps every connection under the 3 req/s average
ASIN_PROP = "ASIN"                      # title property
PRICE_PROP = "Price"                    # number property
CURRENCY_PROP = "Currency"              # rich_text property
CHECKED_PROP = "Checked"                # date property


def notion_headers(token: str) -> dict:
    return {"Authorization": f"Bearer {token}", "Notion-Version": NOTION_VERSION, "Content-Type": "application/json"}


def notion_request(method: str, url: str, token: str, body: dict | None = None) -> dict:
    """One retry on a 429, honouring Retry-After; every other non-2xx is reported, not retried."""
    time.sleep(NOTION_RATE_DELAY)
    resp = requests.request(method, url, headers=notion_headers(token), json=body, timeout=30)
    if resp.status_code == 429:
        wait = float(resp.headers.get("Retry-After", 1))
        time.sleep(wait)
        resp = requests.request(method, url, headers=notion_headers(token), json=body, timeout=30)
    data = resp.json()
    if resp.status_code >= 300:
        raise RuntimeError(f"notion {method} {url.rsplit('/', 1)[-1]}: {resp.status_code} {data.get('message', '')}")
    return data


def existing_pages(data_source_id: str, token: str) -> dict:
    """asin -> page_id for every page already in the data source (paginates at 100 per call)."""
    pages, cursor = {}, None
    while True:
        body = {"page_size": 100}
        if cursor:
            body["start_cursor"] = cursor
        data = notion_request("POST", f"{NOTION_API}/data_sources/{data_source_id}/query", token, body)
        for row in data["results"]:
            title = row["properties"].get(ASIN_PROP, {}).get("title") or []
            if title:
                pages[title[0]["plain_text"]] = row["id"]
        if not data.get("has_more"):
            return pages
        cursor = data["next_cursor"]


def properties_for(price, currency) -> dict:
    return {
        PRICE_PROP: {"number": price},                                   # null clears a stale price, never 0
        CURRENCY_PROP: {"rich_text": [{"text": {"content": currency}}] if currency else []},
        CHECKED_PROP: {"date": {"start": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())}},
    }


def upsert(asin: str, price, currency, data_source_id: str, token: str, pages: dict) -> str:
    props = properties_for(price, currency)
    if asin in pages:
        notion_request("PATCH", f"{NOTION_API}/pages/{pages[asin]}", token, {"properties": props})
        return "updated"
    props[ASIN_PROP] = {"title": [{"text": {"content": asin}}]}
    page = notion_request("POST", f"{NOTION_API}/pages", token,
                           {"parent": {"type": "data_source_id", "data_source_id": data_source_id}, "properties": props})
    pages[asin] = page["id"]
    return "created"


def sync(asins: list[str], data_source_id: str, notion_token: str) -> None:
    session = new_session()
    pages = existing_pages(data_source_id, notion_token)
    checked, problems, stopped = 0, [], ""
    for asin in dict.fromkeys(a.strip().upper() for a in asins):         # dedupe, keep order
        if not ASIN_RE.match(asin):
            problems.append(f"{asin}: not an ASIN, skipped")
            continue
        try:
            data = get_with_retry(session, "amazon-product-offers", asin=asin, marketplaceId=MARKETPLACE)
        except ApiError as err:
            if err.status in (401, 403):
                stopped = str(err)                  # bad key or no credits: every further call fails too
                problems.append(f"{asin}: stopped: {stopped}")
                break
            problems.append(f"{asin}: {err}")       # 404 = listing gone (billed); Notion untouched
            continue
        except requests.RequestException as err:
            problems.append(f"{asin}: {type(err).__name__} after retries, Notion untouched")
            continue
        box = data.get("buyBox") or {}
        price = box.get("totalPrice") if isinstance(box.get("totalPrice"), (int, float)) else None
        currency = (data.get("currency") or {}).get("code")
        try:
            action = upsert(asin, price, currency, data_source_id, notion_token, pages)
        except RuntimeError as err:
            problems.append(str(err))
            continue
        checked += 1
        note = "no featured offer" if price is None else f"{price:.2f} {currency}"
        print(f"{asin}  {action}  {note}")
    for line in problems:
        print(line)
    print(f"{checked} synced to Notion, {len(problems)} problem(s)" + (f", stopped: {stopped}" if stopped else ""))


if __name__ == "__main__":
    sync(ASINS, os.environ["NOTION_DATA_SOURCE_ID"], os.environ["NOTION_TOKEN"])

Two runs: the first creates three pages and reports one gone ASIN; the second updates all three existing pages (illustrative ASINs apart from the documented B0CL61F39H)

--- run 1: one existing page updated, three new ASINs create pages
B0CL61F39H  updated  444.98 USD
B0EXAMPLE1  created  29.99 USD
B0EXAMPLE2  created  no featured offer
B0EXAMPLE3: 404: Invalid product
3 synced to Notion, 1 problem(s)
--- run 2: every page now exists, same ASINs re-synced
B0CL61F39H  updated  444.98 USD
B0EXAMPLE1  updated  29.99 USD
B0EXAMPLE2  updated  no featured offer
B0EXAMPLE3: 404: Invalid product
3 synced to Notion, 1 problem(s)
Table of the second run: four ASINs, the Notion action taken and the price written or the problem reported
B0EXAMPLE3 stays a 404 on every run; its Notion page is never touched.

What the credits and requests actually cost

Every ASIN costs exactly one SellerMagnet credit per sync, whatever the response holds. The Notion side costs API requests, not credits: one query call to find existing pages (more if the watchlist passes 100 rows), then one patch or one create per ASIN. For large lists, run the same offers call inside the worker pool from the bulk ASIN lookup guide.

Cost per sync.
StepCostNote
One /amazon-product-offers call per ASIN1 eachBuy Box price, whatever the run finds
An ASIN that does not exist (404)1Billed; the script counts it as an answer, not a failure
Retry after a 502 or 5031 per attemptA 500 without Retry-After is refunded
The Notion write itself0 SellerMagnet creditsNotion's own rate limit, not a credit cost

What this does not do

  • It does not alert. Unlike the Slack Buy Box alert, this script only keeps Notion current; add a Notion automation or a separate check on the Price property to notify on a drop.
  • It tracks the featured offer, not every seller. buyBox.totalPrice is the one price this script writes; the offer listing API covers every seller on the listing.
  • It needs the database shared with the integration. A database the integration cannot see answers every call with a 404, which looks identical to a deleted database from the API alone.
  • Formulas and rollups are read-only here. The script only writes Price, Currency and Checked; a formula property computed from them updates itself inside Notion.

Frequently Asked Questions

Why query the whole data source first instead of searching for one ASIN at a time?

Querying once per run and building an ASIN to page ID map in memory costs one or two Notion calls for a whole watchlist, instead of one Notion search per tracked ASIN on top of the SellerMagnet call that already costs a credit.

What happens when the ASIN watchlist grows past 100 rows?

A data source query returns at most page_size rows (default and maximum 100) per call. The script follows has_more and next_cursor until every row is read, the same cursor pattern Notion's own docs use for every paginated list endpoint.

Why does a 404 ASIN never touch the Notion page?

A 404 is billed but it means the listing is gone, not that the price dropped to nothing. The script reports it and leaves whatever price Notion already has, rather than writing a value that was never actually read.

Why Price as a number property instead of writing a formatted string?

A Notion number property sorts and filters correctly in a view, and formulas can read it. A rich_text price would display fine but break every numeric filter and sort in the database.

What happens if credits run out mid-run?

The API answers 401 (or 403 during a burst), which is not billed. The script stops instead of calling the remaining ASINs, so no later row is skipped silently; already-synced rows from earlier in the same run keep their new values.

Bottom line: one SellerMagnet call per ASIN, one Notion query to find existing rows, one patch or create per ASIN, and a price that clears to empty instead of lying as 0. The product lookup page lists every response field, and a free account includes 150 credits.

Related Articles

Continue exploring topics related to this article.

Terminal window showing the Amazon Buy Box lost alert a Python script sent as an SMS via Twilio
Amazon API Buy Box Alerts

Amazon Buy Box Lost Alert via SMS: Poll Offers, Confirm, Then Text Yourself with Twilio

Get an Amazon Buy Box lost alert as a text message: poll the live offer listing for each ASIN, compare the featured offer's sellerId with yours, confirm the change on a second check, then send one SMS per run with Twilio's Messages API. Covers the one thing a webhook alert does not have to: Twilio's 2xx answer confirms the message was queued, not that it was delivered.

Nov 19, 2026 Read
Terminal showing a Python price-watch script pushing Amazon Buy Box metrics to a Prometheus Pushgateway for Grafana
Python Amazon API Monitoring

Amazon Buy Box Price Monitoring in Grafana via Prometheus Pushgateway

Push Amazon Buy Box price, availability and offer-count metrics from the SellerMagnet API to a Prometheus Pushgateway, then graph and alert on them in Grafana. sellermagnet.py / retry.py need zero changes from the Python quickstart. The real trap: using push_to_gateway (PUT, a full replace) instead of pushadd_to_gateway (POST, a merge) is what makes a dropped ASIN disappear from the dashboard instead of freezing there forever.

Nov 19, 2026 Read
Terminal running a Python script that computes Amazon's FBA dimensional weight from the lookup response and shows which weight governs shipping
Python Amazon API Reference

Amazon FBA Dimensional Weight Calculator via the API: Volume / 139 in Python

Amazon bills some FBA items on dimensional weight, not scale weight: volume (length x width x height in inches) divided by 139, with a 2-inch floor on bulky items. This guide pulls an item's size and weight from one product lookup, computes the dimensional weight the same way Amazon's own help pages do, and flags which weight actually governs shipping fees.

Nov 19, 2026 Read
Back to Blog

Ready to Extract Amazon Data at Scale?

Start building with SellerMagnet API today. Real-time product data, competitive pricing, and review analytics at your fingertips.

150 free API credits • No credit card required • Cancel anytime