Creating My Own “Best of the Decade” Spotify Playlist
Spotify always does a great job with their end-of-year summaries and “Your Top Songs of 20__" playlists – I love seeing how my taste in music has changed over time.
At the end of 2019, Spotify presented a summary of my top songs and artists for the decade overall. I was hoping they’d wrap this up nicely into something like a “Your Top Songs” playlist as they’ve done for each individual year, and I was excited to see they did publish a “Best of the Decade For You” playlist. Unfortunately, the playlist contained songs I definitely did not recognize, so it wasn’t what I was looking for.
As an alternative, I looked into ways to create a real “Best of the Decade” playlist myself using the Spotify Web API, that contained my 100 most-played songs over the course of my Spotify membership (this is still technically “Best of the Decade” for me because I started using Spotify in the 2011/2012 timeframe).
In this post, I share my notes on trying to create my own “Best of the Decade” Spotify playlist using the Spotify Web API, and provide an overview of the limitations in the Spotify Web API that prevented me from doing exactly what I wanted.
Spoiler alert: I still created a great playlist, filled with throwbacks that span multiple years of listening history. Want to go straight to the code instead of reading? Check out the repo on GitHub.
1. DIY approach
From a functional perspective, I didn’t need too much from the Spotify Web API. I just needed 1) a way to create a playlist, 2) a way to get my most-played Spotify tracks, and 3) a way to add them to the aforementioned playlist. After skimming through the API documentation, it didn’t look like it was going to be too difficult to accomplish:
- The Spotify Web API allows you to create playlists and add tracks to them. Pretty straightforward.
- The Spotify Web API’s “Top Artists/Tracks” functionality allows you to get a user’s top tracks.
Hold up – what exactly do they mean when they say “top tracks”?
2. Spotify doesn’t give you your top tracks by play count
In my original mission, I was specifically looking to get my top tracks based on play count. However, according to Spotify’s API documentation, Spotify’s “Top Artists/Tracks” functionality gets “the current user’s top artists or tracks based on calculated affinity.”
Spotify defines ‘affinity’ as “a measure of the expected preference a user has for a particular track or artist. It is based on user behavior, including play history, but does not include actions made while in incognito mode.” Interesting.
Only being able to get my top tracks based on Spotify’s notion of ‘affinity’ instead of play count was the first road bump I hit, but it wasn’t a showstopper.
3. Spotify calculates “Top Artists/Tracks” over a certain time period
Something else that intrigued me about the “Top Artists/Tracks” functionality was that it calculates your top artists/tracks based on affinity over a certain time frame:
long_term
(Spotify: “calculated from several years of data and including all new data as it becomes available”)medium_term
(Spotify: “approximately last 6 months”)short_term
(Spotify: “approximately last 4 weeks”)1
Given my objective, the only viable option was to use long_term
as my time frame. Although the documentation says long term affinity is “calculated from several years of data and including all new data as it becomes available”, the resulting playlist didn’t look like it included songs from my early days of Spotify (2011/2012-ish).
4. Summary
Despite these two minor road bumps, I stitched everything together pretty quickly and ended up with a personalized throwback playlist that spans multiple years of listening history. I also learned a bit about Spotify’s Web API in the process. I consider that a win.
If you’re interested in the code, check out the repo on GitHub!
1 I can imagine Spotify might use the “Top Artists/Tracks” functionality with time frame set as short_term
to create your On Repeat playlist, which contains your top songs from the past 30 days.