spotichart.spotipy package

Submodules

spotichart.spotipy.audio_features module

spotichart.spotipy.audio_features module.

spotichart.spotipy.audio_features.get_audio_features(access_token, track_id)

Function to fetch the audio features of a song

Parameters:
  • access_token (str) – Spotify Web API Access Token
  • track_id (str) – Spotify Track identifier
Raises:
  • ValueError – Spotify Request Error
  • ValueError – Http Request Error
Returns:

Track’s audio features

Return type:

dict

spotichart.spotipy.main module

spotichart.spotipy.main entry point module.

spotichart.spotipy.main.generate_top_chart(access_token, start, end=None, region='en', chart='top200', sleep=1)

Function to fetch the top chart for a given date, and request their audio features

Parameters:
  • access_token (str) – Spotify Web API Access token
  • start (Date) – Starting point for the scraper to get the top chart
  • end (Date, optional) – Interval for multi-chart table, defaults to None
  • region (str, optional) – Spotify Top 50 region code, defaults to ‘en’
  • chart (str, optional) – Spotify chart to get the data from, either top200 or viral, defaults to ‘top200’
  • sleep (int, optional) – Sleep time for the scraper to rest, defaults to 1
Returns:

Dataframe that stores the chart data, and the audio features for each track

Return type:

pandas.DataFrame

spotichart.spotipy.top_charts module

spotichart.spotipy.top_charts module. Based upon the repo by fbkarsdorp Located on https://github.com/fbkarsdorp/spotify-chart

spotichart.spotipy.top_charts.get_chart(date, region='en', chart='top200')

Download an individual chart

Parameters:
  • date (Date) – Specific date for a Top Chart
  • region (str, optional) – Spotify Top 50 region code, defaults to ‘en’
  • chart (str, optional) – Spotify chart to get the data from, either top200 or viral, defaults to ‘top200’
Raises:

ValueError – Unavailable data requested

Returns:

Top 50 Chart

Return type:

pandas.DataFrame

spotichart.spotipy.top_charts.get_charts(start, end=None, region='global', chart='top200', sleep=1)

Fetch multiple Charts

Parameters:
  • start (Date) – Starting date to download the chart
  • end (Date, optional) – End date for an interval of top charts, defaults to None
  • region (str, optional) – Spotify Top 50 region code, defaults to ‘global’
  • chart (str, optional) – Spotify chart to get the data from, either top200 or viral, defaults to ‘top200’
  • sleep (int, optional) – Sleep time for the scraper to rest, defaults to 1
Raises:

ValueError – Invalid date interval format

Returns:

Chart with the Top 50 basic data

Return type:

pandas.DataFrame

Module contents

spotipy package.