Spotify Playlists & Genres

In previous posts I said I wanted to learn how to extract data from Spotify playlists so this is my initial exploration of that. I used a public playlist called Dance Hits which is constantly changing so don’t be alarmed if your results are different than mine.

I wrote a function that extracted the top songs by popularity from the Dance Hits playlist. Here are the top 20 although my output actually shows more.

Unfortunately, Spotify’s API doesn’t provide a genre tag for each track. Instead, it provides audio features, artist information, and other metadata. I had to resort to finding another API that has song genre so I ended up using API and then finding the genre of the top 20 songs.

The is not great at labelling the song genre. As you can see some songs have genres unknown or weird genres like whistle song so this API is not great.

I graphed the counts of each genre on a bar chart and as expected the top genres of a Dance Hits playlist are dance, house, and party.

In the future, I need to find a much better API because was not ideal for what I needed it for and it seems like the Spotify API is limited as well. My full code and notebook is on Github.