A retrospective on PokeAPI
Paul Hallett
Posted on February 18, 2020
About seven years ago I created pokeapi.co. This is the story of how I built it.
It is always a delight to hear people talk about PokeAPI and how they use it. Sometimes, I don't even mention I built it to those people. I just like seeing how much joy it brings them, and how much they learn from using it. It is a feeling I can't quite describe. I feel like the creation of the site involved a short amount of very intense effort that turned into my most successful thing ever. So it's not like I did anything nobody else could, I just did it first.
And to top it all off, it's about...Pokemon?!
I had graduated university in early 2013. At university I had built a few simple Pokemon battling simulators as I was learning to code. The way the Pokemon video games worked made a lot of sense to me, from a "programming" perspective. It's all about numbers and structured data. I was already a keen Pokemon fan (obviously) and at one point I was even in the top 16 Pokemon trading card game players in the UK. I had even taken the Professor course and judged at competitions.
In 2013, APIs were just beginning to become valuable products, with startups like Twilio and Stripe being the new hotness of the early decade. After I graduated I moved to London to work with a company I had interned at the previous summer. The part of programming that captured my attention was the philosophy behind REST APIs but I didn't see many APIs following this pattern.
So I took the idea of a pure REST API, and then I took the data that was scraped from the games and I built a REST API for it.
The project took me literally one weekend to complete. I sat in this costa coffee shop and bought about ten coffees over two days, stole their wifi, and wrote the entire project. That was all it took.
I created a twitter account for it and shared the project on hackernews and boom I got 2,000 hits in less than a day.
Depression
Let's jump into a side story quickly because I think it is important. I've struggled with mental health since around the time I built PokeAPI. In fact: the reason I was so focussed and hammered it out is because I was in a major depressive peroid and desperately needed some distraction. I had no friends in London, I was running out of money, and I no family there to help me.
I have to deal with mental health every day, and it's hard for me to understand how I produced something like PokeAPI when I was in one of the darkest periods of my mental health journey. But it is what it is, and for the record: I am managing my mental health very well now.
PokeAPI v1
The original version was a debug-mode (yes, I left it in debug mode for about a year) Django project running Tasty pie to expose the data through an HTTP API. It was really janky, it barely held together. I coded the frontend using very basic JavaScript knowledge (I didn't become a proper js developer for at least another five years) and some poor css.
But that didn't matter because it became popular really fast. It even landed me my first real job, where I got to travel around the world and promote APIs. I was incredibly lucky and at the time I had no idea how I had pulled it all off.
PokeAPI v2
Around 2015 the API had served roughly a million requests. I figured out this number by logging each hit in a database table for each month. I would then print out that table in csv format, copy & paste it into a spreadsheet, and then do some excel math to sum the values.
The site was still very janky, but at least I had turned off debug mode by this point. A developer called zaneadix came along and wanted to extend the API to support all the data in the veekun data set. I told them I was happy to let them contribute, and they did, incredibly so. This version was built on the same project but it used Django REST Framework to provide the APIs.
We released v2 of the API around June 2015. The most contribution I did at this point was code review and bug fixing. V2 was a huge success, and I think we hit 25 million API requests about a year later.
Moving towards static sites
So by 2018 I was barely involved in PokeAPI. There was occasional bug fixes and data updates, but a team of people were now managing it all for me, without me asking. Alessandro and Tim became, for all intents and purposes, the core developers of PokeAPI.
At this time I didn't contribute much, and I let the project run stale. I had more important things in life to deal with. I think it's okay to step back from stuff like this. But I could have been more open about it.
The team wanted to help me reduce the cost of the site. It was costing me around $40USD a month to run, purely because it was unoptimised and running on one giant machine on DigitalOcean.
Alessandro and Tim came up with a tool that scraped the site, generated json files, and then hosted them on a server. The frontpage and docs became a separate repo too. This reduced the costs to less than $10USD a month. I maintained the cost for the domain, which was around $30USD a year.
and now
So here we are, in 2020. The project is as strong as ever. We provide about 23 million API requests a month. That's an insane number. It is used for teaching API development all over the world. I see it mentioned in all sorts of blog posts, official documentation examples, and even video game articles.
Here are just a few more articles talking about it.
What more is there to do? It needs new data. It is about a game and a half behind the current series. There are something like 1000 Pokemon now.
It could benefit from some new features. But that would increase the costs. I don't think it will ever be a full time job, because the lawyers will come running at me.
Side note: I met some developers from the Pokemon company, and they love my API. They were keen to collaborate, and I tried to pursue something but it never went anywhere. Their loss, I guess.
I am thinking of coming back to build new stuff. I know it's an excellent resource for learning, and I want to tidy up the source code and use it to show off good open source practices, not just a good API resource for learning.
Also: people keep asking for a search feature. This would not be in the production version, to keep costs down. But it would be easy to add to the open source project. So maybe. Watch this space.
Retrospective
What would I share about this story? Let's do an open retrospective to talk about the good and bad.
Bad
What has gone wrong with this project?
I should stop avoiding issues on the project and address them.
I have not shown enough appreciation for those who helped to keep it alive when I was absent.
Building things are really easy, working with people is hard.
I used to treat every comment as personal criticism. I felt obligated to deal with all issues. That's not okay, and I shouldn't have to.
Good
What has gone well?
It only took a short amount of very intense effort to get this started. My advice to anyone who wants to build something: you can do it! Just try!
It has inspired probably hundreds of people to program. I genuinely wonder how many people have been introduced to programming because of me and the rest of the team. That feeling is just bliss.
It has helped me with my career. Some people say you should run a side project because it will show off what you can do. PokeAPI literally scored me multiple jobs, so that advice was true for me.
I ended up discovering a framework (Django) that I love. I went on to help with it and ended up becoming a Django foundation member.
Parting advice
PokeAPI didn't take me long to build, and it was only a short, intense burst of effort. But I was also very very lucky. Don't feel disheartened if you can't find a niche thing to build. But do keep building stuff - you never know where it might take you. There are hundreds of franchises or things out there that could do with an API; so build one!
Posted on February 18, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.