Most collectors check the same handful of cards over and over, waiting for a price to come down. In this tutorial we'll build a small Python script that does the waiting for you. It keeps a watchlist, checks the Near Mint prices, and posts a message to a Discord or Slack channel when a card falls to your target price or drops sharply since the last check.

What we'll build

You write a watchlist.json file with the cards you care about and a target price for each. A script reads it, finds each card in the API once, and from then on looks up all of them in a single request per batch. When a card's price is at or under your target, or has fallen by 10% or more since the previous run, it sends one line to a webhook. A scheduled job runs it every few hours.

Here are three cards you might put on a watchlist:

Charizard EXGenerations$30.69Near Mint HolofoilSol RingMasterpiece Series: Kaladesh Inventions$1,726.25Near Mint FoilMonkey.D.LuffyOP04: Kingdoms of Intrigue Release Event Cards$85.66Near Mint Normal

What you need

  • Python 3.9 or newer and the requests library (pip install requests).
  • An API key from the dashboard. The script works on every plan. Free looks up one card per request, so it suits a watchlist of about 20 cards. Starter and above can look up 20 or more cards in one request, which makes longer lists cheap.
  • A webhook URL for a Discord or Slack channel (in Discord: channel settings, Integrations, Webhooks; in Slack: an incoming webhook app).
  • Three environment variables: TCGPRICEAPI_KEY, TCGPRICEAPI_URL and ALERT_WEBHOOK_URL. Set CARDS_PER_REQUEST to your plan's number of cards per price request (1 on Free, 20 on Starter, 100 on Pro).

Step 1: write the watchlist

Each entry has a game, a card name, an optional card number to pick one printing, and a target price. Use the game's exact name as GET /v1/sets lists it.

[
  {"game": "Pokemon", "name": "Charizard ex", "number": "", "target": 40.00},
  {"game": "Magic: The Gathering", "name": "Sol Ring", "number": "", "target": 1.50},
  {"game": "One Piece Card Game", "name": "Monkey.D.Luffy", "number": "", "target": 5.00}
]

Targets are in the currency of the prices the API returns for that game. If a name has many printings, add the card number so you watch the one you want. Otherwise the first, best match is used.

Step 2: find each card once

The POST /v1/cards/match endpoint takes a name, an optional number and a game, and returns the best candidates first. We only need the top one. We save its card_id in a small state file, so later runs skip this step entirely and spend no requests on it.

import json, os, requests

API = os.environ["TCGPRICEAPI_URL"].rstrip("/")
HEADERS = {"X-API-Key": os.environ["TCGPRICEAPI_KEY"]}
STATE_FILE = "state.json"

def call(method, path, **kwargs):
    answer = requests.request(method, API + path, headers=HEADERS, timeout=30, **kwargs)
    if answer.status_code == 429:
        wait = answer.headers.get("Retry-After", "a while")
        raise SystemExit(f"Daily limit reached. Retry after {wait} seconds.")
    answer.raise_for_status()
    return answer.json()

def resolve(entry):
    body = {"name": entry["name"], "game": entry["game"], "limit": 1}
    if entry.get("number"):
        body["number"] = entry["number"]
    candidates = call("POST", "/v1/cards/match", json=body)["candidates"]
    return candidates[0]["card"]["card_id"] if candidates else None

A match counts as one request and one card, however many candidates come back. For a 20-card watchlist that is a one-off cost of 20 requests.

Step 3: keep a little memory between runs

The state file holds each card's card_id and the last price we saw, which is what lets the script spot a drop.

def load_state():
    if os.path.exists(STATE_FILE):
        with open(STATE_FILE, encoding="utf-8") as f:
            return json.load(f)
    return {}

def save_state(state):
    with open(STATE_FILE, "w", encoding="utf-8") as f:
        json.dump(state, f, indent=2)

Step 4: look up the prices in batches

POST /v1/cards/lookup takes a list of card_ids and a condition. Each card comes back with a list of SKUs, one per printing, condition and language, and each SKU has a market_price that can be null. For a watchlist we take the cheapest Near Mint price among a card's SKUs.

CHUNK = int(os.environ.get("CARDS_PER_REQUEST", "1"))

def cheapest_near_mint(card):
    prices = [s["market_price"] for s in card["skus"]
              if s["condition"] == "Near Mint" and s["market_price"] is not None]
    return min(prices) if prices else None

def fetch_prices(card_ids):
    found = {}
    for i in range(0, len(card_ids), CHUNK):
        batch = card_ids[i:i + CHUNK]
        data = call("POST", "/v1/cards/lookup",
                    json={"card_ids": batch, "condition": "Near Mint"})
        for card in data["cards"]:
            found[card["card_id"]] = (card["name"], card["set"], cheapest_near_mint(card))
    return found

If you only care about foils, add a printing field to the request body, for example "printing": "Holofoil", and the answer only contains matching SKUs.

Step 5: decide when to alert

An alert fires in two cases: the price is at or under the target, or it is at least 10% below the price from the last run. To avoid repeating yourself every 6 hours, the script remembers whether it already told you about a target hit and only repeats the message when the price changes.

def should_alert(price, target, last):
    reasons = []
    if price <= target and last != price:
        reasons.append(f"at or under your target of {target:.2f}")
    if last and price <= last * 0.90:
        reasons.append(f"down {100 * (last - price) / last:.0f}% since the last check")
    return reasons

Step 6: send the message

Discord expects a content field and Slack expects text, so the script picks one from the URL.

def notify(message):
    url = os.environ["ALERT_WEBHOOK_URL"]
    field = "content" if "discord" in url else "text"
    requests.post(url, json={field: message}, timeout=30).raise_for_status()

The full script

Save everything below as price_alert.py.

import json, os, requests

API = os.environ["TCGPRICEAPI_URL"].rstrip("/")
HEADERS = {"X-API-Key": os.environ["TCGPRICEAPI_KEY"]}
CHUNK = int(os.environ.get("CARDS_PER_REQUEST", "1"))
STATE_FILE = "state.json"

def call(method, path, **kwargs):
    answer = requests.request(method, API + path, headers=HEADERS, timeout=30, **kwargs)
    if answer.status_code == 429:
        wait = answer.headers.get("Retry-After", "a while")
        raise SystemExit(f"Daily limit reached. Retry after {wait} seconds.")
    answer.raise_for_status()
    return answer.json()

def resolve(entry):
    body = {"name": entry["name"], "game": entry["game"], "limit": 1}
    if entry.get("number"):
        body["number"] = entry["number"]
    candidates = call("POST", "/v1/cards/match", json=body)["candidates"]
    return candidates[0]["card"]["card_id"] if candidates else None

def load_state():
    if os.path.exists(STATE_FILE):
        with open(STATE_FILE, encoding="utf-8") as f:
            return json.load(f)
    return {}

def save_state(state):
    with open(STATE_FILE, "w", encoding="utf-8") as f:
        json.dump(state, f, indent=2)

def cheapest_near_mint(card):
    prices = [s["market_price"] for s in card["skus"]
              if s["condition"] == "Near Mint" and s["market_price"] is not None]
    return min(prices) if prices else None

def fetch_prices(card_ids):
    found = {}
    for i in range(0, len(card_ids), CHUNK):
        batch = card_ids[i:i + CHUNK]
        data = call("POST", "/v1/cards/lookup",
                    json={"card_ids": batch, "condition": "Near Mint"})
        for card in data["cards"]:
            found[card["card_id"]] = (card["name"], card["set"], cheapest_near_mint(card))
    return found

def should_alert(price, target, last):
    reasons = []
    if price <= target and last != price:
        reasons.append(f"at or under your target of {target:.2f}")
    if last and price <= last * 0.90:
        reasons.append(f"down {100 * (last - price) / last:.0f}% since the last check")
    return reasons

def notify(message):
    url = os.environ["ALERT_WEBHOOK_URL"]
    field = "content" if "discord" in url else "text"
    requests.post(url, json={field: message}, timeout=30).raise_for_status()

def main():
    with open("watchlist.json", encoding="utf-8") as f:
        watchlist = json.load(f)
    state = load_state()

    for entry in watchlist:
        key = f'{entry["game"]}|{entry["name"]}|{entry.get("number", "")}'
        record = state.setdefault(key, {})
        if "card_id" not in record:
            record["card_id"] = resolve(entry)
            if record["card_id"] is None:
                print("Not found:", entry["name"])
        entry["key"] = key

    ids = [state[e["key"]]["card_id"] for e in watchlist if state[e["key"]].get("card_id")]
    prices = fetch_prices(ids)

    for entry in watchlist:
        record = state[entry["key"]]
        info = prices.get(record.get("card_id"))
        if not info or info[2] is None:
            continue
        name, set_name, price = info
        for reason in should_alert(price, entry["target"], record.get("last_price")):
            notify(f"{name} ({set_name}) is {price:.2f} Near Mint, {reason}.")
        record["last_price"] = price

    save_state(state)

if __name__ == "__main__":
    main()

Run it once by hand to check that it works:

export TCGPRICEAPI_KEY="your-key"
export TCGPRICEAPI_URL="https://tcgpriceapi.com"
export ALERT_WEBHOOK_URL="your-webhook-url"
export CARDS_PER_REQUEST=1
python price_alert.py

To run it on a schedule, add a cron line. Market prices refresh every 6 hours, so checking more often than that only repeats the same numbers:

0 */6 * * * cd /path/to/folder && python price_alert.py

How many requests does it use?

After the one-off setup, each run costs one request per batch of cards. A 20-card watchlist on Free (1 card per request) uses 20 requests a run, so 4 runs a day is 80 of the 100 daily requests. On Starter, with 20 cards per request, the same list uses 1 request a run, or 4 a day, out of 1,000. A 200-card list on Pro (100 cards per request) is 2 requests a run. Starter also has a limit of 1,000 cards a day, which a 20-card list checked 4 times a day stays far under.

Ideas to extend it

  • Add a second target for selling: alert when a card you own rises above a price.
  • Watch a whole set by searching it with GET /v1/cards?game=...&set=... and adding the results to the watchlist.
  • Use GET /v1/cards/{card_id}/history?timeframe=30d on a paid plan to attach a short sold-price trend to each alert. On Starter the history covers 30 days and on Pro it goes back a full year.
  • Swap the webhook for email, a push service or a row in a spreadsheet.
  • Let several friends share one watchlist file and post to a shared channel. For a shared bot that answers commands instead of posting on a schedule, see the Discord price bot guide.

What you could build

  • A price-drop channel for a local game group or a Discord server, with a watchlist everyone can add to.
  • A restocking alert for a shop owner: pings when a card you buy from players becomes cheap enough to buy in volume.
  • A personal sell signal: alerts when cards in your collection pass a price you set.
  • A paid alert service for collectors, with each subscriber's watchlist in a database and one batched lookup per run.
  • A deal feed for a content creator or newsletter.

The prices come from TCGplayer and are passed on exactly as reported. Every paid plan, from Starter up, allows commercial use, so an alert service you charge for is fine on any of them. Free is for personal projects.