Magic The Gathering

Entertainment API · Works globally · MTG sets and cards · No API key

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")
Browse all sets: 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 colors parameter with comma-separated values: colors=red,green. You can also use colorIdentity for multicolor identity matching.
Does the API support pagination?
Yes. Use page and pageSize parameters. Page size defaults to 100, max is 100. Check the totalCount and header links for pagination info.
Can I get card images?
Each card includes an imageUrl field 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