Skip to content

Analyse your Spotify history over the past 12 months with the Spotify API

Notifications You must be signed in to change notification settings

CurtisThompson/spotify-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotify History

This repository is for the analysis of Spotify streaming history files obtained from the Spotify website.

Set-Up

  1. Install Python (version 3 or greater)

  2. Install the pipenv package with pip install pipenv

  3. Download your Spotify streaming data to the data/MyData/ subdirectory

To download your data, you must request the data from the Spotify Account Privacy page. You will then be sent a link to download the data. Note that this step can take a few days.

  1. Obtain Spotify developer authorisation and store keys in data/api_keys/api_dev_keys.txt

Authorisation can be obtained by following the steps listed on the Spotify website. Your two keys should be stored on separate lines within your text file.

Usage

Before calculating any statistics, perform the set-up steps specified in the README. With this step, you should have your own Spotify streaming history to analyse. You should also be able to make Spotify API calls.

To run the complete code and produce visualisations from your streaming history, run:

pipenv run main.py

This will produce a summary visualisation as well as extra visualisations for the top songs, artists, and genres. You can also use the following options with this command:

  • -s (produce a summary visualisation)
  • -t (produce a song (track) visualisation)
  • -a (produce an artist visualisation)
  • -g (produce a genre visualisation)
  • -p (output a pdf of the main statistics)
  • -k [path] (specify the path to the key file)
  • -d [path] (specify the path to the data directory)
  • -y [year] (specify the year to get statistics for)

To calculate individual statistics, instantiate the StreamingHistory class with:

from StreamingHistory import StreamingHistory

You can then call any methods from the class.

Alternatively, you can create all visualisations with the src/create_visualisations.py file.

  1. cd src

  2. pipenv run python create_visualisation.py

This file will be set up to run with the example data, so you will need to change the path to the data within the file.

Contributing

  1. Clone the repo and create a new branch

  2. Make changes and test with data/ExampleData/StreamingHistory0.json

  3. Submit a Pull Request with description of changes

Where possible, please make sure that your changes conform to the Style Guide for Python Code (PEP8).

Example Visualisation

Summary Visualisation

About

Analyse your Spotify history over the past 12 months with the Spotify API

Topics

Resources

Stars

Watchers

Forks