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']}")
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=3for converted mana cost, ormanaCost={2}{R}for exact cost matching. - Does it support foreign languages?
- Yes — the API returns foreign language printings in the
foreignNamesfield for each card when available. - Are card images provided?
- Yes — each card has
imageUrlfor 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=exilesearches rules text, andflavor=wisesearches flavor text across all cards. - Does it include card rulings and legality?
- The
rulingsendpoint provides card-specific rulings. Format legality is indicated in thelegalitiesfield 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
- Commander deck builder with color identity validation
- MTG card price tracker using market pricing data
- Draft booster simulator generating random sealed pools
- Deck legality checker for Standard, Modern, and Pioneer formats
- Card search engine with advanced filtering by set, color, and rarity