API Documentation

The Magic Price API returns fair market values for Magic: The Gathering cards. A machine learning model was trained to understand what a card is truly worth by studying every card, set, variation, and market listing across the game's entire history.

Authentication

All valuation endpoints require an API key passed via the X-API-Key header. Get a free key here. The public preview endpoint (/api/preview) does not require authentication.

curl -H "X-API-Key: mtg_your_key_here" \
  https://mtg-ai-api.fly.dev/api/prices?q=Lightning+Bolt

Endpoints

GET /api/preview

Public preview search. Same response shape as /api/prices but capped at 5 results. No authentication required.

ParameterTypeDescription
qstringrequiredCard name search (partial match)
setstringoptionalFilter by set code
finishstringoptionalFilter by finish: normal, foil, etched

GET /api/prices

Search for card fair market values by name. Returns results grouped by card, with a Market Price and Magic Price per finish. Requires API key.

ParameterTypeDescription
qstringrequiredCard name search (partial match)
setstringoptionalFilter by set code (e.g. LEA)
finishstringoptionalFilter by finish: normal, foil, etched
limitintoptionalMax results (default 50)
offsetintoptionalPagination offset (default 0)
curl -H "X-API-Key: mtg_..." \
  "https://mtg-ai-api.fly.dev/api/prices?q=Lightning+Bolt&set=LEA"
{
  "results": [
    {
      "uuid": "5f8287b1-5bb6-5f4c-ad17-316a40d5b0c",
      "name": "Lightning Bolt",
      "set_code": "LEA",
      "number": "161",
      "rarity": "common",
      "artist": "Christopher Rush",
      "layout": "normal",
      "mana_cost": "{R}",
      "mana_value": 1.0,
      "colors": ["R"],
      "color_identity": ["R"],
      "type_line": "Instant",
      "subtypes": [],
      "supertypes": [],
      "keywords": [],
      "power": "",
      "toughness": "",
      "loyalty": "",
      "defense": "",
      "finishes": ["nonfoil"],
      "border_color": "black",
      "frame_version": "1993",
      "watermark": "",
      "flavor_name": "",
      "flavor_text": "",
      "is_full_art": false,
      "is_promo": false,
      "is_reprint": false,
      "is_reserved": true,
      "is_textless": false,
      "is_alternative": false,
      "magic_prices": [
        {
          "finish": "normal",
          "price": 492.60
        }
      ],
      "market_prices": [
        {
          "finish": "normal",
          "price": 485.20,
          "n_vendors": 4
        }
      ]
    }
  ],
  "count": 1,
  "model_version": "2026-03-18T12:00:00"
}

GET /api/prices/{uuid}

Get the fair market value for a specific card by its MTGJSON UUID. Requires API key. Returns the same response shape as /api/prices.

curl -H "X-API-Key: mtg_..." \
  https://mtg-ai-api.fly.dev/api/prices/5f8287b1-5bb6-5f4c-ad17-316a40d5b0c

GET /api/health

Lightweight health check. No authentication required.

{
  "status": "ok"
}

GET /api/model

Returns metadata about the machine learning model currently powering valuations. No authentication required.

{
  "model_type": "XGBRegressor",
  "test_r2": 0.8942,
  "test_rmse_original": 3.21,
  "training_date": "2026-03-18T12:00:00",
  "feature_count": 121,
  "training_samples": 684000
}

Response Fields

Each card in the results array includes the following fields.

FieldTypeDescription
uuidstringUnique card identifier (MTGJSON)
namestringCard name
set_codestringSet code (e.g. LEA, MH2)
numberstringCollector number within the set
raritystringcommon, uncommon, rare, mythic, bonus, special
artiststringCard artist
layoutstringCard layout (normal, split, flip, transform, modal_dfc, etc.)
mana_coststringMana cost in brace notation (e.g. {2}{U}{U})
mana_valuenumber?Converted mana cost (omitted if not applicable)
colorsstring[]Card colors: W, U, B, R, G
color_identitystring[]Color identity (for Commander)
type_linestringFull type line (e.g. Legendary Creature — Dragon)
subtypesstring[]Subtypes (e.g. ["Dragon", "Spirit"])
supertypesstring[]Supertypes (e.g. ["Legendary", "Snow"])
keywordsstring[]Keyword abilities (e.g. ["Flying", "Haste"])
powerstringPower (creatures only, empty otherwise)
toughnessstringToughness (creatures only, empty otherwise)
loyaltystringStarting loyalty (planeswalkers only)
defensestringDefense value (battles only)
finishesstring[]Available finishes: nonfoil, foil, etched
border_colorstringblack, borderless, gold, silver, white
frame_versionstringFrame era: 1993, 1997, 2003, 2015
watermarkstringWatermark name (if any)
flavor_namestringAlternate flavor name (e.g. Godzilla series)
flavor_textstringFlavor text
is_full_artboolFull art printing
is_promoboolPromotional printing
is_reprintboolCard has been printed before
is_reservedboolOn the Reserved List
is_textlessboolTextless printing
is_alternativeboolAlternate art printing

Each card's magic_prices array carries THE Magic Price — the model's canonical fair value — one entry per finish:

FieldTypeDescription
finishstringnormal, foil, or etched
pricenumberCanonical fair value in USD

Each card's market_prices array carries the live Market Price — the median across distinct retail paper vendors — one entry per finish:

FieldTypeDescription
finishstringnormal, foil, or etched
pricenumberMedian retail price in USD
n_vendorsnumberDistinct vendors behind the median (1 = a lone quote)

Rate Limits

Requests are tracked per API key on a daily basis (UTC). When you exceed your limit, the API returns 429 Too Many Requests. Upgrade from your account page.

TierDaily LimitPrice
Free30 requests$0
Basic50,000 requests$10/mo
UnlimitedUnlimitedCustom

Errors

All errors return JSON with an error field.

StatusMeaning
400Missing or invalid query parameter
401Missing or invalid API key
404No card found for that UUID
429Daily rate limit exceeded
503Service not configured (auth or billing disabled)
{
  "error": "daily limit exceeded (30 req/day for free tier)"
}