A python library for easily graphing and visualizing your Spotify data.
Project description
Splotify
A python library for easily graphing and visualizing your Spotify data.
Documentation
Tutorial
View the Jupyter Notebook tutorial with interactive Plotly plots here.
Installation
Install the library by running:
pip install splotify
Usage
-
First, you need to get your
SPOTIPY_CLIENT_ID,SPOTIPY_CLIENT_SECRET, and redirect uri. Here is a video created by Spotipy that explains how to do so. -
Declare a
SpotifyAPIobject that allows you to access data from Spotify. -
Declare a
Dataobject to store all the songs which you want to plot. You can add individual or multiple tracks, albums, or playlists at a time. -
Determine the kind of data you want to plot:
- Category plots (bar charts, pie charts) allow you to plot songs by groups (i.e. artists or albums).
- Audio Feature Plots allow you to plot songs by their audio features.
-
If you need to look up the Spotify ids of tracks, albums, artists, or playlists, you can use the
search_id(for general searches) ormy_id(for user-specific playlists) functions.
Here is an example analyzing Spotify's "This is Radiohead" playlist:
import splotify.spotifyapi as spotifyapi
import splotify.data as data
import splotify.plots.audiofeatures as af
import splotify.plots.category as c
sp = spotifyapi.SpotifyApi(
"YOUR SPOTIPY_CLIENT_ID",
"YOUR SPOTIPY_CLIENT_SECRET",
"YOUR REDIRECT URI",
)
d = data.Data(sp)
# add tracks from the "This is Radiohead" playlist
d.add_playlist("37i9dQZF1DZ06evO2VxlyE")
# view data about the tracks' audio features
afp = af.AudioFeaturesPlot(sp, d.get_data(), ["energy", "loudness"])
# scatter plot of energy vs. loudness of the tracks in the playlist
afp.scatter_plot_2d(color="album")
# box plot of the tracks' energy values, grouped by album
afp.box_plot(["energy"], groupby="album")
cp = c.CategoryPlot(d.get_data())
# pie chart of albums in the playlist
cp.pie_chart()
This code produces the following plots:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file Splotify-0.1.1.tar.gz.
File metadata
- Download URL: Splotify-0.1.1.tar.gz
- Upload date:
- Size: 1.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b66cc1d5fc863ea1156da3e3664d82393fa4baa01dfb7bcce13a4a7cb63d526
|
|
| MD5 |
dfaa79cadfc24646eb2055553aee82cf
|
|
| BLAKE2b-256 |
db2e328454090749e53412cd1ad37a7800475cae7c0628fbd73fe606d45be752
|