The Spotify API is an extensive API that allows users to not only gather analysis on different artists, but also gather analysis about their own listening habits. People can use this service for a number of different functions, like creating their own year in review or even just reviewing statistics of an artist’s songs. For this markdown I will be looking at the loudest Kanye West tracks.

The API is very easy to setup. In order to set it up you will need a Spotify account, it can be a free or a premium account. Then you will need to logon to this website: https://developer.spotify.com. From there you need to click on your dashboard and choose ‘Create an App’. Once you enter in the app name and description you can grab your Client ID and Client Secret.

Once you have those you can enter them into R to get your access token.

Sys.setenv(SPOTIFY_CLIENT_ID = '')

Sys.setenv(SPOTIFY_CLIENT_SECRET = '')

access_token <- get_spotify_access_token()

These three functions will set up your access token.

You may also need to update your redirect URI by going into your settings on the Spotify developer website.

Here is an example of one of the features the API offers. Once you have you connection made to Spotify you can use commands like this to analyze Spotify.

kanye <- get_artist_audio_features('kanye west')

kanye <-
  kanye %>% 
  arrange(-loudness) %>% 
  select(track_name, loudness, album_name) %>% 
  head(10)

kanye_west <- kanye[1:10, ]
knitr::kable(kanye_west,
             caption = "Loudest Kanye Tracks")
Loudest Kanye Tracks
track_name loudness album_name
No More Parties In LA -1.644 The Life Of Pablo
No Mistakes -2.442 ye
No More Parties In LA -2.526 The Life Of Pablo
Bound 2 -2.821 Yeezus
Breathe In Breathe Out -3.058 The College Dropout
Breathe In Breathe Out -3.099 The College Dropout
On Sight -3.182 Yeezus
Yikes -3.251 ye
Diamonds From Sierra Leone - Bonus Track -3.254 Late Registration
All Of The Lights - Album Version (Edited) -3.280 My Beautiful Dark Twisted Fantasy (Edited Version)

As you can see, No More Parties In LA is the loudest Kanye West song, with songs like No Mistakes and Bound 2 following it.