splotify package

Subpackages

Submodules

splotify.data module

Data class.

This module contains the Data class that stores the tracks you want to plot.

class splotify.data.Data(sp)[source]

Bases: object

Object to store the tracks you want to plot.

Add all the tracks you want to view together in a single plot to a Data instance.

Parameters:

sp (splotify.spotifyapi.SpotifyApi) – A SpotifyApi instance.

add_album(id)[source]

Adds all the tracks on a single album to a Data instance.

Parameters:

id (str) – The URI of the album you want to add. Supports Spotify URIs, Spotify URLs, and Spotify IDs.

add_albums(ids)[source]

Adds all the tracks on multiple albums to a Data instance.

Parameters:

ids (list of str) – The URIs of the albums you want to add. Supports Spotify URIs, Spotify URLs, and Spotify IDs.

add_playlist(id)[source]

Adds the tracks on a single playlist to a Data instance.

Only adds the most recently added 100 songs of a playlist.

Parameters:

id (str) – The URI of the playlist you want to add. Supports Spotify URIs, Spotify URLs, and Spotify IDs.

add_playlists(ids)[source]

Adds the tracks on multiple playlists to a Data instance.

Only adds the most recently added 100 songs of a playlist.

Parameters:

ids (list of str) – The URIs of the playlists you want to add. Supports Spotify URIs, Spotify URLs, and Spotify IDs.

add_track(id)[source]

Adds a single track to a Data instance.

Parameters:

id (str) – The URI of the track you want to add. Supports Spotify URIs, Spotify URLs, and Spotify IDs.

add_tracks(ids)[source]

Adds multiple tracks to a Data instance.

Parameters:

ids (list of str) – The URIs of the tracks you want to add. Supports Spotify URIs, Spotify URLs, and Spotify IDs.

get_data()[source]

Returns all the tracks in a Data instance as a Pandas Dataframe

The returned Dataframe should be passed in while initializing the plot classes, not the Data object itself.

Returns:

A Pandas Dataframe containing the track data added to the Data instance with the columns [“name”, “artist”, “album”, “uri”].

splotify.helpers module

URI search functions.

This module contains functions to help get the Spotify URIs of tracks, albums, artists, and playlists.

splotify.helpers.my_id(sp, limit=10, type='playlist')[source]

Returns and prints the URIs of your personal Spotify playlists.

Parameters:
  • sp (splotify.spotifyapi.SpotifyApi) – A SpotifyApi instance.

  • limit (int, optional) – The number of results you want to view. Defaults to 10.

  • type (str, optional) – The type of URI you want to search up. Defaults to ‘playlist’. Currently only supports ‘playlist’.

Returns:

A nested list. The first list is the names of the columns, and the remaining lists are the search results.

splotify.helpers.search_id(sp, query, limit=10, type='track')[source]

Returns and prints the URIs of public Spotify data.

Returns and prints the URIs of Spotify data that is not user-specific such as tracks, albums, artists, and public playlists.

Parameters:
  • sp (splotify.spotifyapi.SpotifyApi) – A SpotifyApi instance.

  • query (str) – The query you want to search for.

  • limit (int, optional) – The number of results you want to view. Defaults to 10.

  • type (str, optional) – The type of URI you want to search up. Currently only supports ‘track’, ‘album’, ‘artist’, and ‘playlist’. Defaults to ‘track’.

Returns:

A nested list. The first list is the names of the columns, and the remaining lists are the search results.

splotify.spotifyapi module

SpotifyApi class.

This module contains the SpotifyApi class that interacts with the Spotify Web API to fetch your Spotify data.

class splotify.spotifyapi.SpotifyApi(client_id, client_secret, redirect_uri)[source]

Bases: object

Object to fetch Spotify data.

Interacts with the Spotify Web API to fetch your Spotify data. When initialized for the first time, you will need to paste in the URI you were directed to. This SpotifyAPI object is passed into various functions that need to access Spotify data.

Parameters:
  • client_id (str) – SPOTIPY_CLIENT_ID from Spotify developer app you created.

  • client_secret (str) – SPOTIPY_CLIENT_SECRET from Spotify developer app you created.

  • redirect_uri (str) – SPOTIPY_REDIRECT_URI from Spotify developer app you created.

album(id)[source]
audio_features(id)[source]
current_user_playlists()[source]
playlist(id)[source]
search(query, limit, type)[source]
track(id)[source]

Module contents