Magic: The Gathering API

Games API · MTG cards & sets · Official game data

TL;DR

The Magic: The Gathering API provides comprehensive data on all MTG cards from every set ever released (1993 onward). Search by card name, set, color, mana cost, type, subtype, artist, and more. Returns detailed JSON with card images, rulings, foreign language printings, and pricing information. No API key required. Covers over 50,000 unique cards across all rarities and all formats including Standard, Modern, Commander, and Vintage.

Quick start: https://api.magicthegathering.io/v1/cards?name=snap

No API key needed — community-maintained database!

How to Use This API

1. Search by Card Name

https://api.magicthegathering.io/v1/cards?name=snap

2. Filter by Set and Color

https://api.magicthegathering.io/v1/cards?set=khm&colors=R

Red cards from the Kaldheim set.

3. Get All Cards in a Set

https://api.magicthegathering.io/v1/sets/khm/booster

4. JavaScript — Deck Builder Search

async function searchCards(name, colors) {
  const params = new URLSearchParams({ name, colors });
  const r = await fetch(`https://api.magicthegathering.io/v1/cards?${params}`);
  const data = await r.json();
  return data.cards;
}
searchCards('dragon', 'R').then(cards => {
  cards.slice(0, 5).forEach(c => {
    console.log(`${c.name} (${c.manaCost || 'N/A'})`);
    console.log('  Type:', c.type);
    console.log('  Power/Toughness:', c.power + '/' + c.toughness);
  });
});

5. Python — Build a Commander Set

import requests

params = {'commander': 'true', 'colors': 'WU', 'pageSize': 10}
r = requests.get('https://api.magicthegathering.io/v1/cards', params=params)
cards = r.json().get('cards', [])
for c in cards:
    print(f"{c['name']} ({c['setName']})")
    print(f"  Rarity: {c['rarity']} | Type: {c['type']}")
Search "snap": https://api.magicthegathering.io/v1/cards?name=snap

Frequently Asked Questions

How many cards are in the database?
Over 50,000 unique card printings across all sets from Alpha (1993) through the latest standard-legal set.
Can I filter by mana cost or converted mana cost?
Yes — use cmc=3 for converted mana cost, or manaCost={2}{R} for exact cost matching.
Does it support foreign languages?
Yes — the API returns foreign language printings in the foreignNames field for each card when available.
Are card images provided?
Yes — each card has imageUrl for the primary art. Note that some very recent sets may have a slight delay in image availability.
Can I search by rules text or flavor text?
Yes — text=exile searches rules text, and flavor=wise searches flavor text across all cards.
Does it include card rulings and legality?
The rulings endpoint provides card-specific rulings. Format legality is indicated in the legalities field of each card.

API Details

API URL
https://api.magicthegathering.io/v1/cards
Documentation
magicthegathering.io
Category
Games
Authentication
Not Required
Geographic Coverage
Global — all MTG cards, all languages

What You Can Build