Welcome to my first of five dashboard week blogs!
In case you’re asking, what is dashboard week? Dashboard week is a week where, during each day, all the data schoolers create a dashboard and post about it! Monday’s challenge was creating a dashboard using the Spotify API.
What I wanted to create a chart that analysed how the features behind the most popular songs changed over time. To do this, I first extracted the top 200 songs from the Spotify Charts back until the start of 2017. I then used the Spotify API to get features about each song.
Extracting the Top 200
I went about this with a batch macro in Alteryx. The URL is as follows:
This link will download the daily most popular songs in a csv format. To avoid manually downloading all 1,160 csv files I ended up using, I created a batch macro in Alteryx!
The workflow above takes a single date, downloads the csv field by dynamically changing the date in the URL, and then returns the fields I need – namely the rank, number of views and (most importantly) the Spotify ID.
To then call the macro, I created this simple workflow:
Calling the APIs
This is where it gets fun! I used these endpoints from Spotify:
The first API has basic track information, such as the Artist, URL for the image, name, etc. The second API is where it gets interesting as it contains Spotify’s features. I’ll briefly cover the workflow:
It’s best practice to limit the overall API calls needed for a solution, so the first thing the workflow does is create a unique list of the songs. The next thing it does is concatenate the songs into groups of 100 and 50 for the first and second API endpoints respectively. This reduces the list of over 230,000 records to a mere 150 API calls.
Doing this then requires joining the data back to the original list of the Top 200.
One of the most interesting features was valence, which aims to reflect on how happy a song is. For instance, detecting a minor key will result in a lower valence. On the dashboard, there was a download trend in 2017/8 and an upward trend in 2019 (ignoring the Christmas peaks).
As always, thanks for taking the time to read my blog! If you have any comments, suggestions or want to chat, free to connect with me on my LinkedIn!
~ Ryan Edwards