Finding Your Next Favorite Artist on Spotify using Networkx

I have been checking Spotify’s Discover Weekly for a year now, but as much as I appreciate their picks, I find myself favoring, at most, five songs out of the 30 songs recommended. The common thing about the ones I like is that I would click on the profile of the artists behind them, read their bio, and check some of their top tunes.
I realized that I prefer discovering artists rather than discovering songs.
I understand that gems are scarce, and it’s rare for an artist to have more than one hit song, but sometimes one song doesn’t encompass what an artist is all about, and we pass on a chance to explore their discography.
This article explores a strategy for finding new artists on Spotify based on your historical streaming preferences. Each step is accompanied by a Python implementation using Spotify’s API.
The picture below shows the profile page of Stromae (A Belgian artist) on Spotify. Upon clicking on "Fans Also Like", you find a list of up to 50 artists similar to Stromae based on an analysis of the Spotify community’s listening history. The API documentation doesn’t dive into details about similarity measures, but I think it’s a combination of music characteristics and Collaborative Filtering (i.e., if two artists share the same fanbase, then they’re most likely similar).

The "Fans Also Like" list is not informative enough because it only shows similar artists to Stromae but doesn’t take into account my personal historical streaming preferences. In other words, it would be much more helpful to know how similar artists from the "Fans Also Like" page are to other singers from my top 50.

For example, Black M is mentioned as the fourth profile in terms of similarity to Stromae, but I would be interested to know, out of my yearly top 50 artists, how many of them are connected to Black M.
Step I: Retrieving your Spotify streaming data
After creating an account on Spotify for Developers, you will receive an API token to access your streaming history.
Spotify keeps track of your top 50 artists in three different time ranges:
- Short-term: based on your streaming in the last month
- Medium-term: based on your streaming in the past six months
- Long-term: since the creation of your Spotify account
We compile the list of top artists in the three time ranges as follow:
Step II: Creating a network of your favorite artists
The network illustrates how my favorite artists are connected. The large nodes are for artists in my top 50, and the smaller nodes are for other artists related to them. Notice that Black M is linked to 4 artists that I already liked, which means that I should explore his music, although he appeared to be the 4th in terms of similarity to Stromae.

Step III: Ranking artists

Following the same logic, we count each artists’ degree in the network, then exclude the ones from the top 50. The result is a table showing the artists that have the most connections with my top 50 artists. The more connection an artist has, the more likely I would find their music interesting and worth exploring.
Note: I happen to only know about 30% of the artists in this table. But it’s still interesting to see how closely they relate to my top 50 artists.
Including this feature on Spotify would allow users to discover a richer network of artists based on their streaming preferences, which improves our music discovery experience and gives artists a fair amount of attention to their entire body of work.





