Spotify and Tableau. A match made in heaven!

At the Data School, we are nearing the end of our analytics training. For Dashboard Week, day 1, the focus was to use the Spotify API to extract data on either artists or tracks.


The Brief: Use the Spotify API to download track data and visualise it in Tableau.

The Spotify API has multiple endpoints to extract data of your personal use, or to get general trends. My favourite aspect of the Spotify API is the ability to grab ‘audio features’ for track ids.

What are audio features?

Spotify has it’s own propriety algorithms run by “The Echo Nest” that derives the audio features. There isn’t a lot of information available out there.

Danceability: how suitable is a track for dancing?  tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable.
Acousticness: how acoustic is the track. Value of 0.0 to 1.0.
Energy: Measures the intensity and activity. May be derived from the tempo and peaks of the song. Value of 0.0 to 1.0.
Instrumentalness: The closer the value is to 1.0, the greater the likelihood the track contains no vocals.
Liveness: Determines whether the song was performed live or not.
Loudness: The average decibels over the entire track.
Speechiness: Gives a value closer to 1.0 if the track has more ‘speech’. For example, a podcast, talk-show.
Tempo: A value in beats per minute. Generalised as the pace/cadence of the track.\
Valence: The polarity of the track. Whether it is positive or negative. Values closer to 1.0. are positive.

More details can be found on the developer page.

This blog is going to show how I extracted audio features for the Top 100 songs from the Australian and UK Spotify Charts.
The first part uses an Alteryx workflow to prepare the data and then visualising the results in Tableau.


API Download and Data Preparation

Firstly, I downloaded two .csv files from the Spotify Charts website for Australia and the UK.
I’m going to use these data files with the Spotify API to query audio features.

Spotify allows users to create an access token on their developer page. Documentation on how to create a Spotify App can be found here.

After creating a Spotify Developer App I can now access the following fields of data:

username = ‘insert user-id’ #your Spotify username
client_id = ‘insert client id’ #your client id from developer console
client_secret = ‘insert client secret’ #your client secret from developer console

Using the above criteria, I can generate a bearer access token with a macro created by a fellow Data Schooler, Hanna Nykowska in the UK.
This part is essential to extract the audio features from the track ids in the two files I downloaded earlier.

The API endpoint to created to download data is:


Alteryx Workflow Spotify API


I run this workflow twice. Once for Australian Top 100 and the UK Top 100 and union them together. All my data is now ready for some visualytics in Tableau.

Spotify Dashboard Visual Analysis


The Recap

Comparative analysis of the audio features did not show much variance. This seems plausible due to the similarity between Australian culture and British. There was a difference between the stream rate by population. World Population data was blended to normalise the numbers Australia listens to more Spotify songs per capita comparatively and the composition of the songs in the Top 10 differed by position.

Nicholas Hills
Author: Nicholas Hills