
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
js-spotify-api
Advanced tools
A javascript wrapper for Spotify's Web API.
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|---|---|---|---|---|---|
| 67+ ✔ | 52+ ✔ | 16+ ✔ | 54+ ✔ | 16+ ✔ | 11 ✔ |
The library includes helper functions to do the following:
Note: Most of them are still in progress to make (sections marked with TODO)
All methods require authentication, which can be done using these flows:
To use this library you will need a node version >= 6.0.0.
Download one of the follows Node Version Managers to manage the node versions easily:
From npm
$ npm i -S js-spotify-api
From git
$ git clone https://github.com/rubengomex/js-spotify-api.git
$ cd js-spotify-api
$ npm i
You can run the tests by running the follow command:
$ npm t
Note: You only can run the tests if you clone the repository from github
// to import a specific method
import Spotify from 'js-spotify-api'
const spotify = new Spotify({
token: 'YOUR_TOKEN_HERE'
})
// using method
spotify.getArtists({ band: 'Incubus' }).then(artists => console.log(artists))
const Spotify = require('js-spotify-api')
const spotify = new Spotify({
token: 'YOUR_TOKEN_HERE'
})
<!-- to import non-minified version -->
<script src="js-spotify-api.umd.js"></script>
<!-- to import minified version -->
<script src="js-spotify-api.umd.min.js"></script>
After that the library will be available to the Global as Spotify. Follow an example:
const spotify = new Spotify({
token: 'YOUR_TOKEN_HERE'
})
let albums
spotify
.getAlbums({ artist: 'Chosen artist' })
.then(albumsFromArtists => (albums = albumsFromArtists))
.catch(err => console.log(err))
console.log(albums)
// Want to use async/await? Add the `async` keyword to your outer function/method.
async function getUser() {
try {
const response = await spotify.getAlbums({ artists: 'Chosen artist' })
console.log(response)
} catch (error) {
console.error(error)
}
}
NOTE:
async/awaitis part of ECMAScript 2017 and is not supported in Internet Explorer and older browsers, so use with caution.
opts object Specifies the options for spotify class
opts.token string Specifies the spotify token to useMeta
Gets albums info based on albums ids specified
Albums
[{
album_type: 'album',
artists: [ [Object] ],
available_markets: ['AD', 'EC', 'PT', ...],
copyrights: [ [Object] ],
external_ids: { upc: '886445352382' },
external_urls: { spotify: 'https://open.spotify.com/album/{albumId}'}
...
}]
Returns Promise<Array<object>> The albums information
Gets album info based on the id of the album
Album
{
album_type: 'album',
artists: [ [Object] ],
available_markets: ['AD', 'EC', 'PT', ...],
copyrights: [ [Object] ],
external_ids: { upc: '886445352382' },
external_urls: { spotify: 'https://open.spotify.com/album/{albumId}'}
...
}
Returns Promise<object> The album information
Gets the tracks of the album info based on the id of the album
opts object Specifies the options object
Tracks
[{
artists: [ [Object] ],
available_markets: ['AD', 'EC', 'PT', ...],
copyrights: [ [Object] ],
disc_number: 1,
track_number: 1
...
}]
Returns Promise<Array<object>> The album tracks information
See something you think can be improved? Please open an issue for that 😎
FAQs
A javascript wrapper for Spotify's Web API
The npm package js-spotify-api receives a total of 0 weekly downloads. As such, js-spotify-api popularity was classified as not popular.
We found that js-spotify-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.