Learn practical skills, build real-world projects, and advance your career

Analysify

Have you ever analysed your Spotify Playlist? Not? Try it out!

But first you will need to create credentials on the Spotify Developers Website.

Go to Spotify Developers Dashboard, login with your own Spotify Account and create a new "App".

Then go to the top right corner and click on "Edit Settings" and change the "Redirect URIs" to http://localhost.

On the left side you will find the "Client ID" and the "Client Secret", which you will need for the further code shown below.

Here in this project, we will compare two different Spotify Playlists with each other.

The first Playlist is a kind of Synthwave music, the second Playlist pure Classic.

Let's start with the code!

import json
import time
import spotipy
from spotipy.oauth2 import SpotifyOAuth
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

Connect to the Spotify restAPI

Please insert your own credentials for the client_id= and the client_secret=, otherwise we won't be able to the the Playlist details.

sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id="",
                                               client_secret="",
                                               redirect_uri='http://localhost',
                                               scope="user-library-read"))

Definition of our functions to get all details from the Playlists

To be able to get the data we need, we will create 3 functions for this:

  1. Get the Track-ID's from every Track of the Playlist
  2. Get the Artist-ID's for the Tracks. With this we will get 'genres'.
  3. Get the Track detailed data. We can save it into a file.