Web application for viewing historical Spotify artist data.
The app can be accessed at arthistory.brandonscott.me.
The Spotify API provides the current follower count and a popularity score for an artist, but does not provide any historical data. I always wanted to track how my favorite artists were growing over time, so maybe you'll find this app useful too.
Artist data is synced and pushed to a SQLite database stored on S3 with scripts from the scripts package in the repo. This database is pulled down and bundled with the API server on build.
Not every artist on Spotify is tracked, but new artists can be requested through the web UI.
The API requires a SQLite database to query. A small sample database is included in the repo: _spotify-data.db.
The /v1/artists and /v1/artists/search endpoints in the API hit the Spotify API, so you'll need API keys to run them. See the Spotify API documentation on signing up for developer access.
# Edit the environment file to add your Spotify API keys and path to the SQLite database file
cp apps/api/.env.example apps/api/.env
# The environment file for the web app probably doesn't need to be changed.
cp apps/web/.env.example apps/web/.env
# Install packages (ensure you are using Node v20+, run `nvm use` if you have `nvm` installed.)
npm i
# Run a build (This ensures sqlite is built and placed in the right location in the monorepo)
npm run build
# Run the development servers for the web app and API
npm run dev
# Now, open http://localhost:3000 in your browser to view the app.If you find a bug, feel free to open up an issue and try to describe it in detail with reproduction steps if possible.
If you would like to see a feature, and it isn't already documented, feel free to open up a new issue and describe the desired behavior.
Install the service
sudo systemctl enable /home/brandon/arthistory/arthistory-cron-service.serviceStart the service
sudo systemctl start arthistory-cron-service.serviceShow the service status (active, memory, cpu)
sudo systemctl status arthistory-cron-service.serviceList service logs with service-level start/stop/restart events, and stdout/stderr
sudo journalctl --catalog --unit arthistory-cron-service.serviceList service stdout/stderr logs
sudo journalctl --no-pager --unit arthistory-cron-service.serviceList last 1000 lines from the logs and follows the logs
See manpage: journalctl > PAGER CONTROL OPTIONS
sudo journalctl --pager-end --follow --unit arthistory-cron-service.serviceRestart the service daemon & service
sudo systemctl daemon-reload && sudo systemctl restart arthistory-cron-service.serviceUpdating the production database
Ensure you're using the correct node version
nvm useDownload all of the working snapshots from the spotify-data bucket
npm run download-dbsMerge all of the working snapshots into one file
npm run merge-dbsStop the NodeJS process manager running the API instances - if the database file is replaced while it is running, it will crash loop
pm2 stop arthistory-apiMove the merged database file to the production filename
mv merged-spotify-data.db _spotify-data.dbStart the NodeJS process manager running the API instances
pm2 start arthistory-apiUpdating API key permissions to include additional buckets (403 Access Denied error when trying to upload objects)
- Go to the R2 Overview page: https://dash.cloudflare.com/{accountId}/r2/overview
- Click on the Manage button under the Account Details > API Tokens section on the right to land on
- Land on https://dash.cloudflare.com/{accountId}/r2/api-tokens and choose the API token to add additional buckets/permissions to