api.mtgdb.info beta 2.1 (https://www.mtgdb.info)

A card database API for "Magic: The Gathering". Ultra simple. Open source. JSON API to create your own "Magic: the gathering database". Supports http and https.

Download drivers/clients/wrappers:

C# Java
More to come ...

For contact, server status, and updates:

Card Images

    http://api.mtgdb.info/content/card_images/{multiverseid}.jpeg
    https://api.mtgdb.info/content/card_images/{multiverseid}.jpeg

    Large Hi-Res Images
    http://api.mtgdb.info/content/hi_res_card_images/{multiverseid}.jpg
    https://api.mtgdb.info/content/hi_res_card_images/{multiverseid}.jpg
    

Card

    id                  Integer     : multiverse Id
    relatedCardId       Integer     : multiverse Id of a related card, double faced and relying card
    setNumber           Integer     : card number in the set
    name                String      : name of the card
    searchName          String      : easy to search card name
    description         String      : the cards actions
    flavor              String      : flavor text adds story, does not effect game
    colors              String[]    : colors of card
    manacost            String      : the description of mana to cast spell
    convertedManaCost   Integer     : the amount of mana needed to cast spell
    cardSetName         String      : the set or expansion the card belongs to
    type                String      : the type of card
    subType             String      : subtype of card
    power               Integer     : attack strength
    toughness           Integer     : defense strength 
    loyalty             Integer     : loyalty points usually on planeswalkers
    rarity              String      : the rarity of the card
    artist              String      : artist of the illustrations
    cardSetId           String      : the abbreviated name of the set
    token               Boolean     : true if a token card, false if not
    promo               Boolean     : true if a promo card, false if not
    rulings             Ruling[]    : list of rulings for this card
    formats             Format[]    : list of legal formats this card is in
    releasedAt          Date        : when the card was released
	

Ruling

This is the ruling format. The list of rulings is returned in the card object
    releasedAt          Date        : when the rule was released
    rule                String      : the rule
    

Format

This lists the formats a card can be used in and the legality of the card
    name                String      : name of format
    legality            String      : the legality 
    

Get card types

Get http://api.mtgdb.info/cards/types

Get card sub types

Get http://api.mtgdb.info/cards/subtypes

Get card rarity types

Get http://api.mtgdb.info/cards/rarity

Get all cards

Get http://api.mtgdb.info/cards/
Field select
When calling /cards/ a field select can be applied to return only the fields specified. Separate with a comma. This can be combined with filters.
Get http://api.mtgdb.info/cards/?fields=id,name,cardsetid
Filters
Get http://api.mtgdb.info/cards/?colors=white,black
Filters can be applied on any field /?field_name=value. Multple fields can be used. Note that each field is "And" logic. "Or" logic has not yet been implmented.

Get a card

Get http://api.mtgdb.info/cards/[id]

Get cards by multiple Ids

Get http://api.mtgdb.info/cards/[int,int,int,int,...]
This method returns an array of cards by multiverseIds. This is useful for making one call for multiple cards instead of individual calls for multiple cards. example: http://api.mtgdb.info/cards/1,2,3,4,5

Get cards by name

Get http://api.mtgdb.info/cards/[name]
This method returns an array of cards not a single card. When calling by name, the api cannot use colon (":"). For example: "Circle of Protection: Red" will cause an error because of the colon. "Circle of Protection Red" is the proper format. Also special characters that are not used in the english alphabet cannot be used currently.

Simple card search [Alpha feature]

Get http://api.mtgdb.info/search/[text]?start=0&limit=0 <- start and limit are optional
A very basic match search. It will match text in the "searchName" field.

Complex card search [Alpha feature]

Complex search is a powerful search the uses the following syntax:

Fields:

name, description, flavor, color, manacost, convertedmanacost, type, subtype, power, toughness, loyalty, rarity, artist, setId

Compare functions

m : contains, eq : equal to, not : not equal, gt : greater than, gte : greater than or equal to, lt : less than, lte : less than or equal to

Logic

Currently "And" is only supported

Url format

Get http://api.mtgdb.info/search/?q=query goes here&start=0&limit=0 <- start and limit are optional

Get total results of complex search

Currently you will have to requery for the count
Get http://api.mtgdb.info/search/?q=query goes here&total=true <- This will only return and integer

Example:
http://api.mtgdb.info/search/?q=color eq blue and type m 'Creature' and description m 'flying' and convertedmanacost lt 3 and name m 'Cloud'
Example of count:
http://api.mtgdb.info/search/?q=color eq blue and type m 'Creature' and description m 'flying' and convertedmanacost lt 3 and name m 'Cloud'&total=true

Note: When matching text put text with spaces in single quotes example 'giant growth' it is ok to put strings without spaces in single quotes as well.


Get a random card

Get http://api.mtgdb.info/cards/random
This method will return a random card

CardSet

    id          String    : abbreviated name of set   
    name        String    : name of set
    type        String    : the type the set belongs to: eg. Core, Expansion etc ...
    block       String    : name of block the set is part of
    description String    : information about the set
    common      Integer   : amount of common cards in set
    uncommon    Integer   : amount of uncommon cards in set
    rare        Integer   : amount of rare cards in set
    mythicRare  Integer   : amount of mythic rare cards in set
    basicLand   Integer   : amount of basic land cards in set
    total       Integer   : total cards
    releasedAt  Date      : date set was released
    cardIds     Integer[] : multiverse ids of all the cards in the set
	

Get all sets

Get http://api.mtgdb.info/sets/

Get multiple sets

Example: http://api.mtgdb.info/sets/all,arb,ths
Get http://api.mtgdb.info/sets/[string, string, string]

Get a set

Get http://api.mtgdb.info/sets/[id]

Get all cards in a set

Get http://api.mtgdb.info/sets/[id]/cards/
Field select
When calling sets/[id]/cards/ a field select can be applied to return only the fields specified. Separate with a comma. Get http://api.mtgdb.info/sets/[id]/cards/?fields=setnumber,id,name

Get a card in a set

Get http://api.mtgdb.info/sets/[id]/cards/[setNumber]
This is by the card number in the set not multiverse Id

Get a range of cards in a set

Get http://api.mtgdb.info/sets/[id]/cards/?start=1&end=10
Ranges are inclusive, start=1&end=10 will include card 1 to 10 inclusive.

Get a random card in a set

Get http://api.mtgdb.info/sets/[id]/cards/random
This method will return a random card from a set

Please send feature request, comments, corrections or anything else to: planeswalker@mtgdb.info or at GitHub

© 3xS-Rad 2014

All information provided is copyrighted by Wizards of the Coast. This api and/or web applications on this domain are not in anyway affiliated with Wizards of the Coast.