Skip to main content

A fully-fledged installable python package for extracting top 200 and viral 50 charts off of spotifycharts.com

Project description

SPOTIFY CHARTS API (Unofficial)

A fully-fledged installable python package for extracting top 200 and viral 50 charts off of spotifycharts.com

INSPIRATION

This was built to fill the gap left when Spotify deprecated their official Spotify charts API. It arose as a needed crawler for the Spotify data analysis and machine learning project done here

INSTALLATION

pip install fycharts

SAMPLE USAGE

Say you want to extract top 200 daily charts for all time, all regions

from fycharts import SpotifyCharts as ChartsAPI

api = ChartsAPI.SpotifyCharts()
api.top200Daily(output_file = 'top_200_daily.csv')

Run your program. Watch the terminal for helpful information. This information is also logged in a logs.log file

FUNCTIONS AND PARAMETERS

Four functions, for all data you need are required:

  1. top200Weekly
  2. top200Daily
  3. viral50Weekly
  4. viral50Daily

All four functions take the following parameters:

Compulsory

  1. output_file - CSV file to dump the data.

Optional

  1. start - Start date of range of interest as string YYYY-MM-DD
  2. end - End date of range of interest as string YYYY-MM-DD

Refer to 'PASSING DATES AS PARAMETERS' below for important information on this.

  1. region - Region of interest, as a country abbreviation code. 'global' is also valid

Refer to 'SUPPORTED COUNTRY CODES SO FAR' below for important information of this.

If not included, data is extracted for all dates, all regions

DATA RETURNED

The data extracted from spotifycharts.com is written into a CSV file with the following fields:

  1. position - The song's position during that week or day
  2. track name - Name of the song
  3. artist - Name of artist
  4. region - Region of the chart as a code
  5. date - Date or range of dates of chart
  6. id - Spotify track id
  7. streams - Number of streams for that week or day. Only applicable to top 200 charts

SUPPORTED COUNTRY CODES SO FAR

'global', 'ad', 'ar', 'at', 'au', 'be', 'bg', 'bo', 'br', 'ca', 'ch', 'cl', 'co', 'cr', 'cy', 'cz', 'de', 'dk', 'do', 'ec', 'ee', 'es', 'fi', 'fr', 'gb', 'gr', 'gt', 'hk', 'hn', 'hu', 'id', 'ie', 'il', 'is', 'it', 'jp', 'lt', 'lu', 'lv', 'mc', 'mt', 'mx','my', 'ni', 'nl', 'no', 'nz', 'pa', 'pe', 'ph', 'pl', 'pt', 'py', 'ro', 'se', 'sg', 'sk', 'sv', 'th', 'tr', 'tw', 'us', 'uy', 'vn'

PASSING DATES AS PARAMETERS

For V1.0.0 dates need to be passed following some strict guidelines.

  1. Data goes as far back as 2017-01-05 for viral 50 weekly, 2016-12-22 for top 200 weekly, and 2017-01-01 for all daily.
  2. Due to (1) above, when passing the start date esp. for weekly data, the date must be i + (7 days * n) where i: First date defined in (1) above, and n: number of weeks. If the date isn't valid, you shall be notified with a list of valid dates
  3. The API returns data up to and excluding the date passed in the 'end' parameter

STUFF YOU SHOULD KNOW

When extracting data for a range of dates, in loop, the crawler sleeps every iteration for a random number of seconds between 0 and the index of the date. Dig into the code to change this!!!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fycharts-1.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

fycharts-1.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file fycharts-1.1.1.tar.gz.

File metadata

  • Download URL: fycharts-1.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for fycharts-1.1.1.tar.gz
Algorithm Hash digest
SHA256 24915c10835636118da57dc270ce313d9009a54f0664c68010eeee5191e4e51d
MD5 f3d98c65d8b5194c6fa17191b2dae7d2
BLAKE2b-256 05b4da5dab3f2f3f7cbbe82c571519de28245dacf8c702c5887a3193d4cf94ad

See more details on using hashes here.

File details

Details for the file fycharts-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: fycharts-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for fycharts-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63f3125969575ce1be775bd9b7b3fa866efbda8838ba565163106f8e5a3d64a3
MD5 bb0fce142488d64ebfa48c72e916b554
BLAKE2b-256 6cfadd0a811c4b24ab1c0cec03c709a5a8e750cb8f38919d6633c68a8d11882d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page