Soccer CLI - How a simple CLI app went viral
20 Oct 2015Sunday evening, I am working on my laptop while Barclays Premier League commentary is playing in the background. I am trying to do two things simultaneously but I am able to do none.
Since the work has to be done urgently, I switch off the TV. But now, I am constantly switching between my terminal and browser to check the scores, after all it’s Manchester United who is playing.
This has happened to me dozens of time and every time I wish I didn’t have to leave my terminal to check the scores. As a developer, my job is to find the solution. It was then the idea of soccer-cli came to me.
A month and dozens of pull requests later:
It’s been more than a month since I “launched” soccer cli and it got:
- Close to 250 stars on Github
- Number 1 trending python repo on Github
- Over 25k downloads on PyPi
- Many more happy and productive football fans
One of the geekiest things I've ever seen...and it's awesome! https://t.co/LiEuKRd5Yx
— Oliver Roick (@oliverroick) September 3, 2015
sudo pip install soccer-cli; soccer --league=LLIGA. Aun hay gente que sabe hacer programas DE VERDAD.
— Raul Herranz (@rahego_) September 4, 2015
Translation: sudo pip install soccer-cli; soccer –league=LLIGA. There are still people who know how to REALLY program.
Soccer scores from the command line. Brilliant.
https://t.co/vzloPoQsRC
— Jon Crowell (@jonrcrowell) September 2, 2015
This open source command-line interface for soccer scores is pretty cool: http://t.co/ibMJsinORe pic.twitter.com/Pxs7cwd5Nv
— Alex Sanchez (@_alxsanchez) September 3, 2015
Soccer scores for hackers. Awesome. architv/soccer-cli · GitHub http://t.co/jXWKrmf66T
— Bill Horvath II (@billhorvath) September 12, 2015
It even made it’s way to Pycoders weekly newsletter
It was on Vietnam’s hackernews too!
The plan was not to create the next trending repo (even if it were, it would have been fine). it was to solve a problem that I myself was experiencing.
How?
There were three basic things which were used to create soccer-cli:
Football API
The first task was to get the football scores. After a bit of looking for it, I stumbled across Joe Kampschmidt’s awesome curation of all the source for getting data.
Since, I had no intention to pay for the API, I looked for the free ones. I tried both openfooty API and football-data API. Openfooty API had a stale community and it was hard to get an API key. football-data API on the other hand, had a good documentation, easy to get an API key and scores were updated fast enough to match my needs. So, I went ahead with it.
Live Scores
While the football-data API updated the scores fast enough, it still didn’t implement real-time scores. So, to fix this problem I decided to create my own API to get live scores. It’s a simple with just a single endpoint which fetches the scores from ESPN and spits it out in the json format
Click
Since the tool was entirely command line, I needed an easy way to get and parse command line arguments. click came to my rescue. From it’s documentation:
Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It’s the “Command Line Interface Creation Kit”. It’s highly configurable but comes with sensible defaults out of the box. It aims to make the process of writing command line tools quick and fun while also preventing any frustration caused by the inability to implement an intended CLI API.
End
Doing all this has been fun. I have learnt a lot more about python through various pull requests. Open source is awesome, you get to learn new concepts and apply them.
The rewards are amazing, seeing people love what I made and talk about it, makes me extremely happy and proud.
If you liked this post, you can share it with your followers!