Trailpack to connect your app with the Spotify API
$ npm install --save trailpack-spotify-api
// config/main.js
module.exports = {
packs: [
// ... other trailpacks
require('trailpack-spotify-api')
]
}
// config/spotify.js
module.exports = {
clientId: 'your-client-id',
clientSecret: 'your-client-secret'
}
This package is a wrapper for the 'spotify-web-api-node', the functions reference is available at here.
Usage example:
// api/services/spotify.js
module.exports = class SpotifyService extends Service {
/**
* Get Elvis' albuns
*/
getElvisAlbuns() {
return this.app.spotifyApi.getArtistAlbums('43ZHCT0cAZBISjO8DG9PnE')
}
}
You can also access user private information using 'trailpack-passport' with Spotify OAuth2 to authentication workflow and obtain the access token.