Display your Spotify stats on your bio.
This is a simple node app that uses Spotify Web API to get a user's currently playing track and displays it on their GitHub bio (and possibly other platforms in the future). This app runs a scheduled job every 3 minutes using node-schedule to query for the currently playing track and updates the bio.
Currently, I have an instance running as a process locally on my own device using pm2. You can see it in action on my GitHub profile bio. There are no plans to deploy the app and support multiple users at the moment, but feel free to run it yourself.
- Spotify and GitHub accounts
- Node.js v18 or higher (this project uses Node's built in fetch API)
- A Spotify app with a client ID and client secret (see here for more info)
- A GitHub personal access token with
user
scope (see here for more info) - Redis running locally (see here for more info)
-
Install dependencies
npm install
or
yarn install
-
Create a
.env
file in the root directory based on the.env.example
file. Ensure that theSPOTIFY_REDIRECT_URL
matches the redirect URL you set in your Spotify app settings and should be something likehttp://localhost:8888/callback
if you're running the app locally. Spotify will redirect to this URL after the user authorizes the app which will then exchange the authorization code for an access token and refresh token (auth code flow).
You may build the app using npm run build
or yarn build
and then run it using npm run start
or yarn start
.
Alternatively, you may run the app in development mode using npm run dev
or yarn dev
.
In the initial run, you will have to authorize the app to access your Spotify account. You may do so by visiting
http://localhost:8888/login
in your browser.
PM2 is a process manager for Node.js applications. It allows you to run your app in the
background as a daemon and provides a lot of useful features such as automatic restarts, logs, and more.
Install PM2 globally using npm install pm2 -g
or yarn global add pm2
. You may then run the app using
pm2 start "node -r dotenv/config /path/to/your/build/index.js"
.