So you want an MtG API

What’s an API?

An API is a service that a computer can talk to, in order to get information about a certain topic, or to operate another program remotely.

Why would you need an API for Magic: The Gathering?

If you wanted to write a mobile app which displays information about MtG cards, you either need to load all of that data (about 10MB) into your app and update it every 3 months, or use some service to provide it all, ad-hoc. There is an official site called Gatherer, which displays information about any card you want, but computers can’t read it — it’s meant for people.

What are the options?

I’ve been working on my own card API for a little while now, but today I’ve discovered quite a few other interesting services. Since I’m in the market of filling an unfilled role, I don’t have any special competitive spirit for my own product, so here’s a rundown of what you can use:

magic-api

This is my product. I just released the v1.1 beta [view the super cool and funny* release notes]. It’s open source, so anyone can use, modify, and host their own. It lets you search for a card by name, and returns data structured in JSON. The returned data is in a simpler structure than the other services here. (*Lie)

Update: I now host a pretty version of magic-api called Scry (http://scry.me.uk)

Example query: Hopeful Eidolon on magic-api

Search the City

StC has a pretty website! It queries magiccards.info instead of Gatherer and allows you to search by property instead of just individual card names. The return data is just right. It’s really quite good!

Example query: Hopeful Eidolon on Search the City

Also, it supposedly shares a JSON format with the MTG JSON project…

MTG JSON

This isn’t actually an API; it’s an up-to-date database of all cards, in JSON. Could be a useful fallback if you need your application to work offline.

mtgapi

This is another standard API that does what it says on the tin. It returns JSON but doesn’t set the content-type header (at time of writing), which is annoying.

Example query: Hopeful Eidolon on mtgapi

Hope you have fun developing or learning!

Ste

Advertisements

About stegriff

Aspiring man of God. Professional computer geek. "Not a hipster".

2 responses to “So you want an MtG API

  1. Hey man I stumbled across this post while researching for a project. I want to have a website for my store and have an online database of all the cards we have in stock. Could you do something like this, or do you know of anything for WordPress I could use? Thanks…

    • Hi Mark!

      First off, I don’t know of any extensions for WordPress. Instead, you could customise magic-api in a few ways, but it depends whether you really need all of that stuff about card text/rules/artists in your DB. Currently magic-api works by adding a card to the DB the first time it is searched for. You would want to make that feature private to you, the admin, so it only contains cards you have in the store. If you’re ok with learning or writing a little bit of PHP and SQL, you could add a database field for number-in-stock for each card, plus a function to decrease that figure when you sell one.

      Sadly, I can’t offer my services to help you with development right now, because I’m busy with my job and uni work, but I wish you all the best for your project! :)

      Ste

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: