A while back I created an R package to pull data out of the Spotify API and turn it into a d3.js visualisation. Here is the blogpost. I’ve started to teach myself Python and I’ve now re-built this process with it. The exciting part is, as it’s in Python I can use the Google App Engine to create an app that hosts the code online. That means anyone can generate a related artists visualisation. Hurray! Have a go yourself by following this link
To find out more about how its done read on…
I learnt some basic Python using code academy. Then taking some lessons from when I built this in R, I decided rather than mess about with the data in data frames, the important bit is to create the json for the data. So this time I just iterate through the results adding them to my json string. It’s much quicker now. I used the urllib package to pull in from the API and json package to convert into the json data form.
I already knew about the google app engine after reading this blogpost. Next I went through their online tutorial. It explains how to use webapp2 to make your process work as a web page. Then the Handling Forms section explains about requesting data using; RequestHandler with the get option, and then pushing back out the results with the RequestHandler post option.
That’s it really. To try out the app click here
My code can be found in this github repo