If you are not a subscriber of The Fanbase Builder, join the hundreds of artists, creators, and music industry executives who receive it for free.
Let’s dive into today’s topic:
Retrieving catalogue data using the Spotify Web API
Last week, we generated an access token for Spotify’s Web API. Today, we’ll explore how to retrieve Spotify catalogue data using the API.
Why it matters
Spotify relies heavily on machine learning and AI to serve the tastes of every niche. Multiple algorithms translate music into zeros and ones to create personalised recommendations and to compose playlists such as Discover Weekly and Daily Mix. A basic understanding of how Spotify categorises music is valuable knowledge.
How it works
Here's how to retrieve catalogue data using Spotify's Web API:
Step 1: Get the artist and track IDs
Identify the artist and track of interest and obtain their corresponding IDs.
I randomly scrolled through the ‘Woman of Electronic’ playlist on Spotify and selected the Sofia Kourtesis track ‘Si Te Portas Bonito’ as an example for this manual.
Artist ID
On the artist profile in the Spotify Desktop app, click the three dots next to the ‘Follow’ button > Share > Copy link to artist.
Paste the result somewhere in a text document.
open.spotify.com/artist/7wXTWO45lqpUejDkike0Gf?si=WodonnJwTMmteBUPBFBfIA
The part after
artist/
and before?si=
is Spotify’s Artist ID for Sofia Kourtesis:7wXTWO45lqpUejDkike0Gf
Track ID
Click the three-dotted button beside the track name > Share > Copy Song Link.
Paste the result somewhere in a text document.
open.spotify.com/track/5Qa679CkfZaEEsLGUBfXFp?si=e8580eaa689d4eb9
The part after
track/
and before?si=
is Spotify’s Track ID for Si Te Portas Bonito:5Qa679CkfZaEEsLGUBfXFp
Step 2: Obtain an access token
Follow last week’s manual to generate an access token for Spotify’s Web API. Copy the access token for later use.
Step 3: Get Spotify catalogue data
We have collected the following variables in the previous steps:
Artist ID
7wXTWO45lqpUejDkike0Gf
Track ID
5Qa679CkfZaEEsLGUBfXFp
Access Token
Here are some examples of utilising the access token and IDs to fetch relevant catalogue information.
Please note: This manual is written from a macOS perspective. There are some suggestions for altering the cURL syntax for Windows.
Example 1: Get Artist
The Get Artist endpoint shows which genre(s) Spotify assigns to the artist and their popularity.
Run this code. Replace
{{ACCESS_TOKEN}}
with the one generated in step 2.
curl "https://api.spotify.com/v1/artists/7wXTWO45lqpUejDkike0Gf" \
-H "Authorization: Bearer {{ACCESS_TOKEN}}"
If everything goes well, the response shows Spotify’s catalogue information about the artist:
{
"followers" : {
"total" : 63499
},
"genres" : [ "experimental house" ],
"name" : "Sofia Kourtesis",
"popularity" : 49,
}
Example 2: Get Artist's Related Artists
The Get Artist's Related Artists endpoint shows the artists Spotify categorises as similar to the chosen artist.
Run this code. Replace
{{ACCESS_TOKEN}}
with the one generated in step 2.
curl "https://api.spotify.com/v1/artists/7wXTWO45lqpUejDkike0Gf/related-artists" \
-H "Authorization: Bearer {{ACCESS_TOKEN}}"
If everything goes well, the response shows a long list of related artists, their genres, and their followers:
{
"artists" : [ {
"followers" : {
"total" : 23946
},
"genres" : [ "electra" ],
"name" : "Elkka",
"popularity" : 40,
}, {
"followers" : {
"total" : 47689
},
"genres" : [ "ukg revival" ],
"name" : "Logic1000",
"popularity" : 50,
} ]
}
Example 3: Get Track's Audio Features
The Get Track's Audio Features endpoint shows how Spotify indexes songs on mood-specific variables like danceability, liveness and valence, with 0 typically being low and 1 being high. Spotify’s documentation goes into more detail.
Run this code. Replace
{{ACCESS_TOKEN}}
with the one generated in step 2.
curl "https://api.spotify.com/v1/audio-features/5Qa679CkfZaEEsLGUBfXFp" \
-H "Authorization: Bearer {{ACCESS_TOKEN}}"
If everything goes well, the response shows the tracks’s audio features:
{
"danceability" : 0.715,
"energy" : 0.847,
"key" : 6,
"loudness" : -9.978,
"mode" : 0,
"speechiness" : 0.0440,
"acousticness" : 0.000532,
"instrumentalness" : 0.265,
"liveness" : 0.200,
"valence" : 0.709,
"tempo" : 121.981,
"duration_ms" : 301851,
"time_signature" : 4
}
Go deeper: Retrieving more catalogue data.
There’s much more data accessible than these three examples.
Explore the Web API documentation on Spotify for Developers for additional endpoints.
Read my earlier writings on this subject in the ‘Further reading’ section below.
Yes, but..
This is technical and geeky stuff. However, understanding how machines interpret music is crucial in the modern music landscape, which is driven by algorithms.
Take action now
Artists can generate an access token using last week’s manual and start exploring their own Spotify catalogue data using the provided examples.
Your thoughts
Join the conversation and share your insights on retrieving Spotify catalogue data with hundreds of artists, creators, and industry professionals.
Disclaimer
Data responses have been edited for clarity, focusing on relevant information.
Further reading
How to access the Spotify Web API (The Fanbase Builder)
Web API Documentation (Spotify for Developers)
How Spotify’s algorithms listen to music (The Fanbase Builder)
Learn how the Spotify AI categorises your music in 30 minutes (Artist Lockdown Challenge)
Transforming music marketing from algorithms to authenticity (The Fanbase Builder)
very cool! can we tweak these values?