Spotify API playlist followers

One of Spotifys best features [and arguable growth hack] is its public & shareable playlists. These allow users to share & discover new music via playlists - and if youre a music professional you may be very interested in capturing trends to see which artists are making an impact via playlist appearances.

In this article well discuss how to scrape a users playlists [with playlist follower counts], and then how to scrape the individual tracks from those playlists [with popularity metrics for each track]. This can help you track how well artists are doing on Spotify based on playlist data.

Well be using the Spotify Web API, specifically the Get Users Playlists, Get Playlist, and Get Playlist Items endpoints.

Scraping With Stevesie Data

Well be using the Stevesie Data Platform to access these API endpoints and extract the data out in easy-to-use CSV files. Stevesie Data is a paid platform and the rest of this article assumes you have the plus plan for running workflows. Disclaimer: I, the author of this article, happen to own the Stevesie Data Platform.

If you dont want to use the platform, youre welcome to follow the concepts below and access the endpoints listed above directly with your own software.

1. Scraping Spotify User Playlists

If you dont already have a list of playlists you want to analyze, you can get a list from a popular account, like the Official Spotify Account - just click on the link See All under Public Playlists to see all of Spotifys Public Playlists.

Here, well scrape basic information about the playlists, including their names and number of tracks. Simply import the Spotify User Playlists - Pagination workflow into your account and you can then provide a Spotify username [or list of names] to look up the playlists for:

Let the workflow run and it will scrape 50 playlists per page and then combine all the results together:

Open up the CSV file and it will look something like this:

Note that the only details we get here are the number of tracks per playlist, which isnt entirely useful. To get more data, we need to copy the items.id column [highlighted above] and look up the details in the next step.

2. Scraping Spotify Playlist Follower Counts

When tracking popularity, it typically helps to know the follower count for what youre tracking. Once you have a list of Playlist IDs [either from step 1 above or from your own methods], you probably want to know how many followers each playlist has before digging too deeply into the tracks in a playlist.

E.g. if youre looking for up-and-coming artists, you probably care if a very popular playlist includes a relatively unpopular track then we can expect that track [and respective artist] to grow in popularity.

So to get the Playlist Follower Counts for a list of Playlist IDs, we want to import the Spotify Playlist Details - Multiple Playlist IDs and paste in a list of Playlist IDs:

For this example, we just used the first 100 playlists on Spotifys page, but you can enter as many as you want. After executing the workflow, well see the results:

And we can download the Spotify_Playlist_Details.csv file [1 row for each playlist], which will contain the follower count for each playlist:

Note that although we see a Spotify_Playlist_Tracks.csv file returned, dont get too excited. It is not exhaustive and does not contain ALL the tracks per playlist. To ensure we get ALL the tracks for each playlist, well have to do another lookup using our list of 100 Playlist Item IDs below.

3. Scraping Spotify Playlist Tracks & Artists

Now for our final act, well collect ALL of the playlist tracks as well as the associated artists [with album IDs] from all the tracks in the 100 playlist IDs we examined in step 2.

Simply import the Spotify Playlist Tracks - Multiple Playlists formula to add the worlfow into your account, and paste in the list of Playlist IDs like before:

Once finished, youll see a few results files, including Playlist_Tracks.csv with the full 9,040 rows in it [compared to 7,700 from the previous step]:

Now when you open Playlist_Tracks.csv youll see details about each track, notably a items.track.popularity field with a score between 0 and 100:

Spotify doesnt reveal exactly how this score is calculated, though the play count most likely has an influence on the score and we can generally assume that tracks with higher popularity scores will tend to have higher play counts. You can use this data as youd like and it may help you spot up-and-coming tracks [e.g. if you find tracks with low popularity scores on popular playlists, you can put your money on that track getting more popular].

Artist Scraping

While the Playlist_Tracks.csv sheet includes information about artists, it only shows the first artist for each track [since there can be multiple artists]. To get all of the artists responsible for tracks [as well as the associated popularity scores], just download the Track_Artists.csv file:

Now you can see that if a track has more than one artist, it is duplicated to provide a row for each artist so you can see the full picutre and identify any up-and-coming artists or track how dominant artists are amongst popular playlists.

Video liên quan

Chủ Đề