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
obj = ChartsAPI()
obj.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:
- top200Weekly
- top200Daily
- viral50Weekly
- viral50Daily
All four functions take the following parameters:
Compulsory
- output_file - CSV file to dump the data.
Optional
- start - Start date of range of interest as string YYYY-MM-DD
- end - End date of range of interest as string YYYY-MM-DD
Refer to 'PASSING DATES AS PARAMETERS' below for important information on this.
- 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:
- position - The song's position during that week or day
- track name - Name of the song
- artist - Name of artist
- region - Region of the chart as a code
- date - Date or range of dates of chart
- id - Spotify track id
- 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.
- 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.
- 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
- 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
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
Built Distribution
File details
Details for the file fycharts-1.0.1.tar.gz
.
File metadata
- Download URL: fycharts-1.0.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7aed1339e9aae7780579329389d8da226e11afd38ac263ee6615537ade34f979 |
|
MD5 | d36e7f8ba88df34e9c4c948040d3f7df |
|
BLAKE2b-256 | f7dce3ec7e8e9454c24d0731a30447552c0f5d3129bf6557e69929b1de6f2387 |
File details
Details for the file fycharts-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: fycharts-1.0.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2773f41cd7c94b928da21aafd9953ac66bfb318f6f3a9d7565281ccc964801bd |
|
MD5 | b3e9f45ad588bac081320a7fa617d4f1 |
|
BLAKE2b-256 | a68294980b505f84d4970fe7d6770a4d47822e2f197812d420fc3b9b0032381e |