Extracting Scryfall Magic the Gathering Data: 1 (Python)
Jump to Code/Solution
If you want to skip my blurb about Magic the Gathering go straight to the scryfall python notebook which offers an entry-level intro to getting trend-price, and loads of other card and set data from the scryfall api.
About MtG and Me
About 24.5yrs ago I started playing a complex and—it has been said, ‘geeky’—card game called Magic the Gathering. I spent most of my discretionary income on Magic cards for about a year or so, then sold my best cards and kind of gave it up.
Just learned last year (through a friend) that Magic is still alive and well. Not only that, but has thrived, nay, surged with respect to its popularity and global footprint over the past 20yrs. It has been interesting getting back into the game, listening to podcasts, reading strategy articles, poring over the hundreds of sets that have been released, and marvelling at how well the game creators and designers have managed to develop the game over the decades. They have kept it strategically fresh, economically profitable, and creatively stimulating. What really surprised me was that there is a network of regional, national, and global competitive events, running weekly from Fukuoka, Japan to Fife, Scotland!
I could say more; but suffice it to say I got interested in playing again, then I quickly got interested in the data! :)
Magic the Gathering Data
You can scrape data from TCG Player, and I tapped the Wizards API also a while ago at https://magicthegathering.io/ but for some time I lacked a robust source of price data that I could use to see how prices were trending over time, for every print of every card. Eventually, through a series of efforts I found a way of tapping the Scryfall API to get cardmarket trend price data at the time of extracting. I figure this can be run weekly, then this will give me a database of card price movements over time.
Tapping into Scryfall’s API
I use Python code to access the API. And the best way to share that is with a Jupyter notebook. Rather than pasting images of my jupyter notebook here, I will just point to my github repository where you can easily see the scryfall api notebook and commentary, and follow along with my journey of getting to grips with the API.
The code essentially uses python to tap the API and extract desired data fields to a csv file.