Skip to content
Switch branches/tags
Go to file


Failed to load latest commit information.
Latest commit message
Commit time
Apr 17, 2017
Apr 4, 2017
Apr 17, 2017
Apr 17, 2017
Apr 17, 2017

Spotify Player

A Node.js server plus a light JS library to create integrations with the Spotify Web API Connect endpoints.

Using the library

Import the script Now you can log the user in and listen to updates on playback:

var spotifyPlayer = new SpotifyPlayer();

spotifyPlayer.on('update', response => {
  // response is a json object obtained as a response of

spotifyPlayer.on('login', user => {
  if (user === null) {
    // there is no user logged in or the user was logged out
  } else {
    // the user is logged in
    // user is a json object obtained as a response of

loginButton.addEventListener('click', () => {

logoutButton.addEventListener('click', () => {


Have a look at for an example of a visualization using this library.

The library uses a shared server to issue the initial access token and refreshed tokens. This means your integration could reach Spotify's rate limits easily. If you want to have more control on this, deploy the code to your own server using the following instructions.


The server can be run locally and also deployed to Heroku. You will need to register your own Spotify app and pass the credentials to the server. For that:

  1. Create an application on Spotify's Developer Site.
  2. Add as redirect uris both http://localhost:5000/callback (for development) and <production_domain>/callback (if you want to deploy your app somewhere)
  3. Keep the client ID and client secret somewhere. You'll need them next.

Running Locally

Make sure you have Node.js.

$ npm install
$ CLIENT_ID=<your_client_id> CLIENT_SECRET=<your_client_secret> REDIRECT_URI=<your_redirect_uri> npm start

Your app should now be running on localhost:5000.

Deploying to Heroku

You will need to have the Heroku CLI installed.

$ heroku create
$ git push heroku master
$ heroku open


Deploy to Heroku

You will then need to set the environment variables using heroku config:set:

$ heroku config:set CLIENT_ID=<your_client_id>
$ heroku config:set CLIENT_SECRET=<your_client_secret>
$ heroku config:set REDIRECT_URI=<your_redirect_uri>


A wrapper around Spotify Connect to interact with the player



No releases published


No packages published