125 comments

[ 4.7 ms ] story [ 178 ms ] thread
This looks great! I would be interested in talking to the creator about making a plugin based on this for DuckDuckGo if they're around and so inclined.
Jaryd: email if mtgpdb@gmail.com if you would like to get ahold of me. reply
I'm interested in where the database came from. Is this all manually compiled or pulled from a general source?
All source is pulled form the gatherer. Public Information
It's a cool API, I like it.

Just be careful because Wizards of the Coast might disagree with you about what is and isn't public information. Especially when you are showing the rating and number of votes and rating straight from Gatherer.

Is this available for the Pokemon cards?
No it is not, but can add that to the code fairly easy :P
Honestly I'd love just a Pokedex API. It seems like the best right now is Veekun's work[1]. It just needs to be...API-fied.

Nintendo is very happy to give out C&Ds though, which might explain why such a thing doesn't already exist.

[1] https://github.com/veekun/pokedex

I'm actually working on that—hopeful to have something passable out by the release of X/Y.
Awesome! Are you using Veekun's database, or do you have your own source?

Edit: Wait, you are Veekun! Or at least I think you are, "eevee"'s GitHub profile links to Veekun's website.

veekun is my project, yes :)
Is this so that someone can build a Pokemon Snap AR game for our smartphones?
Now someone needs to use this to make a passable Magic AI. Shandalar is ancient at this point, but it's still the best attempt I've seen, and the only Magic computer game I still play.
I'm not sure if you're aware of Forge or not, but it's actively developed and will probably give you a better game than Shandalar.

http://www.slightlymagic.net/wiki/Forge

I was about to post the same comment. Forge is actually pretty good. And I agree that it's better than Shandalar. I played Shandalar again maybe 5 years ago and the AI gets predictable so fast.
I was not aware of Forge. Thanks! I guess I stopped paying attention about 10 years ago, shortly after WotC killed Apprentice. I figured, based on their behavior, that they would never let any unlicensed innovative MTG software come out. I'm glad they proved me wrong.
Cockatrice is the successor to Apprentice, and is still around even after a recent C&D from WotC. The reason the C&Ds come along is because they all tend to use terms and concepts that WotC owns, like tapping cards.

http://cockatrice.woogerworks.com

There is a Wizards product called Duels of the Planeswalkers that includes an updated Magic AI. $10 on the consoles or Steam. It is targeted as an entry-level way to learn Magic.

http://en.wikipedia.org/wiki/Magic:_The_Gathering_–_Duels_of...

It focuses on premade decks with limited means of customization, rather than open freeform deckbuilding. (Of course they want you to start buying Magic proper to do that.) But it is the only official way to play modern Magic against an adequate AI.

Wait, so how do I use this to buy and sell bitcoins?
Why bother with bitcoins? Magic cards are much better currency.
No joke, I wasn't aware of how much value there is in MTG until a friend of mine put down $6000 investing in a bunch of cards. Then again, I don't know all that much about the game, but you can see that the market for cards on eBay is really active.
Some of my friends made good money playing the market: They bought during the summer drought and sold just after Christmas, when the kids had gotten money as presents.
You do know mtgox used to be a web site whose original owner hoped to use as a place to buy and sell Magic cards, right?

MTGOX == Magic: The Gathering Online eXchange

(Edit: As someone pointed out already.)

Jaryd: email if mtgpdb@gmail.com if you would like to get ahold of me.
This gave me a flashback to Mox Perl.

Until I saw Mox Perl, I had no idea that web pages could be dynamically-generated by computer programs. It truly blew my mind and triggered a year-long love affair with Perl.

Would be sweet to search by characteristics other than id and name.

Eg all GG creatures with power greater than 3

Nonetheless sweet job!

You might want an SQL like interface for that?
Are you planning anything beyond multiverse ID and text search? I usually need to filter by many attributes. Specifically searching in the flavor text, filtering by format legality, card color, converted mana cost, etc.

Gatherer offers all of these abilities but not in an easy to use API. Even if you query gatherer programmatically you're still stuck scraping the page to get the data.

it is coming :) no worries stay tuned
Do you have permission to pull data from Gatherer? If so, you should also have the image url in your response. That'd be awesome
any plans to add art?
Dang. A nice looking system that does exactly what I was hoping to do with a project of mine that lost my interest.....

Oh well. I appreciate the whole api but what I would really enjoy is the source to where the database is acquired from. I presume it is gatherer but could be wrong because there is at least another site that could be scraped. That or they are scraping a storefront which would be interesting and efficient.

And does it handle double sided cards? That's the thing that buggered my scrapping to the point of annoyance. Damn Innistrad and it's double sided creatures!

double sided cards are seen as separate crds at this point . It is a point for improvement though!
I wish you luck, they are painful unless you feel like trying to parse card text. At that point you might as well write a bot that plays magic for you....
This is absolutely awesome.

I have a few thoughts right off the bat.

1.

It would be nice to put a Gatherer link in every response, just for browsing purposes.

2.

Split cards are weirdly reported, as if they are two separate cards. In Gatherer these are reported with an id and a "part" field:

  http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=249394&part=Malice
It looks like you're only getting the first part. See that Spite//Malice is missing from

http://mtgapi.com/api/v1/fetch/search/malice

But I can search for "spite" and I find:

http://mtgapi.com/api/v1/fetch/id/249394

3.

It looks like you're using the Oracle text for every version (for example, http://mtgapi.com/api/v1/fetch/id/198 and http://mtgapi.com/api/v1/fetch/id/226588 have the same rules text, though they appeared differently when printed). Is there any way to get that information? That could be really cool for mining information about how terminology has changed over time.

thanks for the feedback! will keep that in mind in the next few days!
From one of their examples:

    [
	{
		"id": "202424",
		"name": "Tundra",
        ...
        }
    ]
id# is in the 200000s ? Are these allocated sequentially and contiguously ? If so, M:tG _really_ got away from me since I stopped paying attention to it.
I don't think they are allocated sequentially (and there aren't that many unique cards/versions). But IIRC Gatherer's using the IDs from the internal "Multiverse" DB, which also includes all the brainstormed card ideas that never made it into an actually-released set, which would tend to inflate the numbers.

Edit: and they are not allocated sequentially. These two cards have only ever appeared in the 2014 core set, and have sequential collector numbers in the set but not sequential IDs:

http://gatherer.wizards.com/Pages/Card/Details.aspx?multiver...

http://gatherer.wizards.com/Pages/Card/Details.aspx?multiver...

This is probably the geekiest thing I've seen all week.
Now, it would be nice to have some kind of DSL to encode the `text' field.
Another recently popular game which may be of interest to HN is Android: Netrunner. It is an asymmetrical game wherein one player is the corporation who has a set of servers and is trying to advance adgenda cards while the other player is the runner, who is trying to hack into the corporation's servers with a set of programs, hardware and other resources. Like Magic, there is the actual game play, but then also the meta game play of picking cards to customize decks to play each role.

It shares the same designer as Magic (Richard Garfield), but is a Living Card Game rather than a Collectable Card Game. The difference being that in Magic you spend tons of money hoping for the random drop of particular rare cards or buy them individually from dealers. In A:NR, they release a new "data pack" about once a month and then have mini-expansions maybe once a year. It's more like a subscription model, but the net effect is that every card is worth the same as every other card. Still not a cheap hobby, but capped, at least (maybe about $175 to buy every card ever made up to today).

Anyways, someone built a RESTy API for it as well: http://netrunnercards.info/apidoc/en.html

Not only that but the game is completely different to Magic. It comes from an earlier time, before the idea of "turn cards sideways to show they've been used" took hold. It has a very different economy and the two sides play completely differently.

The LCG data-pack model is great for people playing constructed formats, but it does make drafting more of a challenge. Mature LCGs are also quite difficult for latecomers to get into, especially if key packs go out of print.

> It comes from an earlier time, before the idea of "turn cards sideways to show they've been used" took hold.

Netrunner came out 3 years after Magic.

I didn't say that it predated magic, I said that it came about before the idea of turning cards sideways (as "tapping", "kneeling", "exhausting", "rotating") became an entrenched mechanic.
It really didn't.

M:TG and Netrunner were both designed by Richard Garfield and Netrunner's design was directly influenced by his experience with M:TG.

Cards in Netrunner aren't tapped because actions in Netrunner are limited by a player's "clicks", not just their available resources.

It was a design decision.

(comment deleted)
Luckily it looks like A:NR is at least an order of magnitude more popular than previous LCGs so the cards should stay in print for a while - a bigger issue is that at a certain point, the need to have a 'complete' set is going to be a very expensive proposition. But I agree, the downside of not having a built-in obsolescence/reissue function is that old cards might go out of print.

On the other hand, it's just so much better to play. It actually feels like they made a big list of everything that is wrong about MTG and fixed it.

They also had the chance to undo mistakes and rebalance things from the original Netrunner.

The constant release of new data packs is eventually going to become really tough for new players. I hope they run some kind of restricted tournament format (e.g., only the core + most recent data pack cycle + most recent big box expansion) so that the keen newbie doesn't have so much of a buy-in, but they can grow into the open constructed format later.

Thanks for posting this. Looks interesting. Something to play with my eldest daughter I think.

I ended up being the local card exchange at university for MTG which was uber-popular. Selling cards made me a fortune simply by enforcing scarcity on some of them and auctioning by email (I wrote an auction system in procmail and perl designed to maximise profit). Made £1320 profit in a year!

Edit: just found my old card database. Had 1540 cards at one point! Still have a box in the cupboard as well according to my wife.

I play this one with my daughter:

http://gos.bigosaur.com

Only thing bothering me is that she has to pick the almost useless Unicorn each time - because it looks nice. ;)

Thanks looks interesting. You can't win when unicorns are involved unfortunately :(
Ahh Magic cards! The first website I ever made was a magic card trivia page, oh about 15 years ago. If I had known about this API, I would have used it back then ;)

By the way, there is an awesome program called lackeyCCG[1] that I use whenever I feel the need for a quick fix, it's almost like a free version of magic online. Plus you can use it to test your own CCG's if you ever had the urge to make one.

[1] http://www.lackeyccg.com/

Cockatrice is another good one: www.woogerworks.com
I don't suppose you'd provide snapshots of the database that's backing this API?
(comment deleted)
This is very nicely done. Wish this was available when I was developing CardSplice as it would have saved me some time.

Shameless plug for CardSplice[1] since hacker news is talking about MTG. I had a ton of fun developing this awesome app that lets you quickly feed Magic Cards behind your mobile and uses some advanced image processing and OCR to detect the cards and upload the list into the cloud. Amazing for draft deck building and organizing.

Anyways, thanks for the MTG web service.

[1] http://www.CardSplice.com

This would be much more useful if it had prices and card images.

www.mtgprice.com looks like a really good price API, but I haven't tried it out yet.

Fun fact: mtgox (the Bitcoin exchange) originally stood for "Magic: The Gathering Online Exchange" and was a site for buying/selling "Magic: The Gathering" cards.
I wish people would stop repeating this.

The domain was just reused, the site was never actually sold cards.

The current owner has absolutely nothing to do with the original domain name.

(comment deleted)
He didn't say anything about the current owner, only the original intent of the name. Even then, I think your reaction might be a little over the top.
The insinuation is that the current site is somehow tainted by it's use back in 2007, but as far as I can find [1] it was never anything but a "coming soon"page.

It's fairly common to ridicule it's current use in the Bitcoin world by associating the currency exchange with playing cards.

[1]: http://web.archive.org/web/20070817170606/http://mtgox.com/g...

Why would anyone consider mtg something worthy of ridicule?
Because it's a game played by nerds. :)

But seriously, associating MtGox with a place to sell playing cards might detract from the serious intentions of the site. Idk.

The same reason they consider bitcoin worthy of ridicule.
No way. MTG is super awesome; the fact that Mt.Gox is indirectly linked to Magic only makes it cooler.
Nop, mtgox stand for "MagicalTux" aka Mark Karpeles who was historically called "MT".

Source : Close friend and : https://twitter.com/magicaltux

These people are not my close friends (I occasionally contacted them by IRC or E-mail for support, probably more often their employees) but

I am pretty sure that Jed was the person who started the business, and he sold it to MagicalTux. This would indicate that it's a coincidence that MT in MagicalTux is like MT in MtGox. Maybe MagicalTux chose his nickname for this reason.

I know MagicalTux since 1999. So when I said "close friend" I meant, I was used to call him "MT" in real life 13 years ago.
So, he also knew Jed for so long and the service was named with him in mind?

Or I am totally wrong about the origin of the service...

You know when you're a geek when you see "Magic: The Gathering" & "API" in the same sentence and click the link without a second thought.