Spotify Web Playback is a TypeScript-enabled API for using the Spotify Web Playback SDK.
The Spotify Web Playback SDK enables developers to stream and play Spotify tracks in any web browser that supports Encrypted Media Extensions (currently only FireFox, Google Chrome, and Microsoft Edge are supported).
See the Web Playback SDK Quick Start for a quick introduction to the Web Playback SDK, and the Web Playback SDK Reference for a more complete API reference.
npm i -s spotify-web-player
or
yarn add spotify-web-player
const token = 'SPOTIFY_TOKEN';
const uri = 'spotify:album:51QBkcL7S3KYdXSSA0zM9R';
const spotify = new SpotifyPlayer();
await spotify.connect(token);
spotify.play(uri);
This library does not handle obtaining a Spotify token. You have to take care of that yourself.
You have two options:
An example of #2 is included. Please see demo.mjs and public/demo.mjs for more information.
Set CLIENT_ID
and CLIENT_SECRET
then run npm run demo
and open http://localhost:8989/
to view the demo.
Much of the inspiration for this API comes from Gil Barbara's react-spotify-web-playback.
Licensed under the MIT license. See LICENSE.md for more details.
Generated using TypeDoc