Andrew Backes

Magic: The Gathering API

A simple MTG API for developers looking to create their own MTG application.

Overview

The Magic: The Gathering API is a free, simple to use API that delivers MTG card and set data in JSON.

The API is written in Ruby on Rails, while the data is all stored in PostgreSQL.

This project was originally created while learning Ruby on Rails, but as of today, serves around 1 million requests a week.

Here is a sample requests/response:

GET https://api.magicthegathering.io/v1/cards?name=zurgo&set=ktk

{
   "cards":[
      {
         "name":"Zurgo Helmsmasher",
         "manaCost":"{2}{R}{W}{B}",
         "cmc":5,
         "colors":[
            "White",
            "Black",
            "Red"
         ],
         "colorIdentity":[
            "W",
            "B",
            "R"
         ],
         "type":"Legendary Creature — Orc Warrior",
         "supertypes":[
            "Legendary"
         ],
         "types":[
            "Creature"
         ],
         "subtypes":[
            "Orc",
            "Warrior"
         ],
         "rarity":"Mythic Rare",
         "set":"KTK",
         "setName":"Khans of Tarkir",
         "text":"Haste\nZurgo Helmsmasher attacks each combat if able.\nZurgo Helmsmasher has indestructible as long as it's your turn.\nWhenever a creature dealt damage by Zurgo Helmsmasher this turn dies, put a +1/+1 counter on Zurgo Helmsmasher.",
         "artist":"Aleksi Briclot",
         "number":"214",
         "power":"7",
         "toughness":"2",
         "layout":"normal",
         "multiverseid":386731,
         "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=386731&type=card",
         "watermark":"Mardu",
         "rulings":[
            {
               "date":"2014-09-20",
               "text":"You still choose which player or planeswalker Zurgo Helmsmasher attacks."
            },
            {
               "date":"2014-09-20",
               "text":"If, during your declare attackers step, Zurgo is tapped or is affected by a spell or ability that says it can't attack, then it doesn't attack. If there's a cost associated with having Zurgo attack, you aren't forced to pay that cost, so it doesn't have to attack in that case either."
            },
            {
               "date":"2014-09-20",
               "text":"If Zurgo enters the battlefield before the combat phase, it will attack that turn if able. If it enters the battlefield after combat, it won't attack that turn and will usually be available to block on the following turn."
            },
            {
               "date":"2014-09-20",
               "text":"Each time a creature dies, check whether Zurgo had dealt any damage to it at any time during that turn. If so, Zurgo's ability will trigger. It doesn't matter who controlled the creature or whose graveyard it went to."
            }
         ],
         "foreignNames":[
            {
               "name":"碎盔珠高",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=387000&type=card",
               "language":"Chinese Simplified",
               "multiverseid":387000
            },
            {
               "name":"碎盔珠高",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=387269&type=card",
               "language":"Chinese Traditional",
               "multiverseid":387269
            },
            {
               "name":"Zurgo Helmbrecher",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=387538&type=card",
               "language":"German",
               "multiverseid":387538
            },
            {
               "name":"Zurgo Brisecasque",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=387807&type=card",
               "language":"French",
               "multiverseid":387807
            },
            {
               "name":"Zurgo Spaccaelmi",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=388076&type=card",
               "language":"Italian",
               "multiverseid":388076
            },
            {
               "name":"兜砕きのズルゴ",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=388345&type=card",
               "language":"Japanese",
               "multiverseid":388345
            },
            {
               "name":"투구분쇄자 주르고",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=388614&type=card",
               "language":"Korean",
               "multiverseid":388614
            },
            {
               "name":"Zurgo Quebra-elmo",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=388883&type=card",
               "language":"Portuguese (Brazil)",
               "multiverseid":388883
            },
            {
               "name":"Зурго Шлемобой",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=389152&type=card",
               "language":"Russian",
               "multiverseid":389152
            },
            {
               "name":"Zurgo Aplastacráneos",
               "imageUrl":"http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=389421&type=card",
               "language":"Spanish",
               "multiverseid":389421
            }
         ],
         "printings":[
            "pPRE",
            "DDN",
            "KTK"
         ],
         "originalText":"Haste\nZurgo Helmsmasher attacks each combat if able.\nZurgo Helmsmasher has indestructible as long as it's your turn.\nWhenever a creature dealt damage by Zurgo Helmsmasher this turn dies, put a +1/+1 counter on Zurgo Helmsmasher.",
         "originalType":"Legendary Creature — Orc Warrior",
         "legalities":[
            {
               "format":"Commander",
               "legality":"Legal"
            },
            {
               "format":"Legacy",
               "legality":"Legal"
            },
            {
               "format":"Modern",
               "legality":"Legal"
            },
            {
               "format":"Vintage",
               "legality":"Legal"
            }
         ],
         "id":"7e30597e0e1a8ced89a78b7776134b600998fb13"
      }
   ]
}

Interested?

Check it Out