https://github.com/oliverfindl/spotify-current-track
Simple wrapper class for obtaining current track from Spotify Web API.
https://github.com/oliverfindl/spotify-current-track
api current javascript spotify spotify-current-track track web wrapper
Last synced: about 1 year ago
JSON representation
Simple wrapper class for obtaining current track from Spotify Web API.
- Host: GitHub
- URL: https://github.com/oliverfindl/spotify-current-track
- Owner: oliverfindl
- License: mit
- Created: 2018-07-21T19:52:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-02T13:49:51.000Z (over 7 years ago)
- Last Synced: 2025-03-18T14:07:02.339Z (about 1 year ago)
- Topics: api, current, javascript, spotify, spotify-current-track, track, web, wrapper
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spotify-current-track
[](https://www.npmjs.com/package/spotify-current-track)
[](https://www.npmjs.com/package/spotify-current-track)
[](https://www.npmjs.com/package/spotify-current-track)
[](https://paypal.me/oliverfindl)
Simple wrapper class for obtaining current track from [Spotify](https://www.spotify.com/) Web API.
---
## Install
Via [npm](https://npmjs.com/) [[package](https://www.npmjs.com/package/spotify-current-track)]:
```bash
$ npm install spotify-current-track
```
Via [yarn](https://yarnpkg.com/en/) [[package](https://yarnpkg.com/en/package/spotify-current-track)]:
```bash
$ yarn add spotify-current-track
```
## Usage
```javascript
// require lib
const SpotifyAPI = require("spotify-current-track");
// init lib
const spotify = new SpotifyAPI({
// [required] fill in your spotify credentials
clientId: "",
clientSecret: "",
refreshToken: "",
// [optional] override default request timeout, defaults to 0 (no timeout)
_timeout: 1000 // milliseconds
});
// [optional] set market
spotify.market = "SK";
// get current track
spotify.currentTrack.then(track => {
// ...
}).catch(console.error);
```
`clientId` and `clientSecret` can be obtained from your own [Spotify App](https://developer.spotify.com/documentation/general/guides/app-settings/).
`refreshToken` can be obtained by [Authorization Code Flow](https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow) with `user-read-currently-playing` and/or `user-read-playback-state` scope.
Set `market` if you want to apply [Track Relinking](https://developer.spotify.com/documentation/general/guides/track-relinking-guide/).
Example `track` object can be found [here](https://developer.spotify.com/documentation/web-api/reference/player/get-the-users-currently-playing-track/).
---
## License
[MIT](http://opensource.org/licenses/MIT)