TL;DR
The Magic: The Gathering API (magicthegathering.io) provides structured data about MTG cards, sets, types, and subtypes. Query by card name, set, color, mana cost, or any other attribute. Each card returns full Oracle text, flavor text, mana cost, converted mana cost, power/toughness, rarity, artist, and legalities across all formats. The API is RESTful, returns JSON, and requires no authentication. Covers cards from the earliest Alpha set through the most recent expansion.
Quick start: https://api.magicthegathering.io/v1/sets
No API key needed — just make a request!
How to Use This API
1. List All Sets
https://api.magicthegathering.io/v1/sets
2. Search Cards by Name
https://api.magicthegathering.io/v1/cards?name=snap
3. Filter by Color + Type
https://api.magicthegathering.io/v1/cards?colors=red&type=instant
4. JavaScript — Find Cards by Mana Cost
fetch('https://api.magicthegathering.io/v1/cards?cmc=3&colors=blue')
.then(r => r.json())
.then(data => {
data.cards.forEach(card => {
console.log(`${card.name} — ${card.manaCost}`);
});
});
5. Python — Count Cards by Rarity
import requests
cards = requests.get(
'https://api.magicthegathering.io/v1/cards',
params={'set': 'm19'}
).json()
rarities = {}
for card in cards.get('cards', []):
r = card.get('rarity', 'unknown')
rarities[r] = rarities.get(r, 0) + 1
for r, count in sorted(rarities.items()):
print(f"{r}: {count} cards")
https://api.magicthegathering.io/v1/sets
Frequently Asked Questions
- What card fields are returned?
- Each card includes: name, manaCost, cmc, colors, colorIdentity, type, types, subtypes, rarity, set, setName, text, flavor, artist, number, power, toughness, layout, multiverseid, imageUrl, and legalities for all formats.
- How do I search by multiple colors?
- Use the
colorsparameter with comma-separated values:colors=red,green. You can also usecolorIdentityfor multicolor identity matching. - Does the API support pagination?
- Yes. Use
pageandpageSizeparameters. Page size defaults to 100, max is 100. Check thetotalCountand header links for pagination info. - Can I get card images?
- Each card includes an
imageUrlfield when available. Scryfall is generally preferred for high-quality card images. - What sets are covered?
- All official Magic: The Gathering sets from Alpha (1993) through the latest expansion are included, plus some special sets and promo releases.
- Is there a rate limit?
- The API is free to use without a rate limit documented. However, excessive requests may be throttled. Cache results in production applications.
API Details
- API URL
https://api.magicthegathering.io/v1- Documentation
- docs.magicthegathering.io
- Category
- Entertainment
- Authentication
- Not Required
- Geographic Coverage
- Global
What You Can Build
- Deck builder with card search by name, color, mana cost, and type
- Card collection tracker with rarity counts and set completion stats
- Draft helper that suggests picks based on color and mana curve
- Format legality checker — which cards are legal in Standard, Modern, Commander
- Card database app with Oracle text search and artist information