simple-spotify-wrapper
v3.0.7
Published
A small and awesome wrapper to get general information from the Spotify Web API.
Downloads
5
Maintainers
Readme
Simple Spotify Wrapper
A small and awesome wrapper to get general information from the Spotify Web API.
Installation
You can install the library using npm
:
$ npm i simple-spotify-wrapper
or using yarn
:
$ yarn add simple-spotify-wrapper
How to use
ES6
// import the library
import SpotifyWrapper from 'simple-spotify-wrapper';
// create a instance
const spotify = new SpotifyWrapper({
token: 'PUT YOUR TOKEN HERE'
});
const albums = spotify.search.albums('Choose your artist');
albums.then(data => console.log(data.albums));
CommonJS
var spotifyWrapper = require('spotify-wrapper');
UMD in Browser
<!-- to import non-minified version -->
<script src="spotify-wrapper.umd.js"></script>
<!-- to import minified version -->
<script src="spotify-wrapper.umd.min.js"></script>
After that the library will be available to the Global as SpotifyWrapper
. Check this example:
const spotify = new SpotifyWrapper({
token: 'PUT YOUR TOKEN HERE'
});
const albums = spotify.search.albums('Choose your artist');
albums.then(data => console.log(data.albums.items));
Methods
Below are all the methods that the library provide:
- search.artists(query)
- search.albums(query)
- search.tracks(query)
- search.playlists(query)
- album.getAlbum(id)
- album.getAlbums(ids)
- album.getTracks(id)
search.artists(query)
Search for informations about Artists with provided query. Test in Spotify Web Console with type defined as artist.
Arguments
| Argument | Type | Options |
|----------|---------|-------------------|
|query
|string | 'Any search query'|
Example
search.artists('Isadora Pompeo')
.then(data => {
// do what you want here
})
⇯ go back
search.albums(query)
Search for informations about Albums with provided query. Test in Spotify Web Console with type defined as album.
Arguments
| Argument | Type | Options |
|----------|---------|-------------------|
|query
|string | 'Any search query'|
Example
spotify.search.albums('Isadora Pompeo')
.then(data => {
// do what you want here
})
⇯ go back
search.tracks(query)
Search for informations about Tracks with provided query. Test in Spotify Web Console with type defined as track.
Arguments
| Argument | Type | Options |
|----------|---------|-------------------|
|query
|string | 'Any search query'|
Example
spotify.search.tracks('Isadora Pompeo')
.then(data => {
// do what you want here
})
⇯ go back
search.playlists(query)
Search for informations about Playlists with provided query. Test in Spotify Web Console with type defined as playlist.
Arguments
| Argument | Type | Options |
|----------|---------|-------------------|
|query
|string | 'Any search query'|
Example
spotify.search.tracks('Isadora Pompeo')
.then(data => {
// do what you want here
})
⇯ go back
album.getAlbum(id)
Search for informations about a specific Album with a id.
Arguments
| Argument | Type | Options |
|----------|---------|-------------------|
|id
|string | 'Specific id'|
Example
spotify.album.getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want here
})
⇯ go back
album.getAlbums(ids)
Search for informations about a specific Album with their ids.
Arguments
| Argument | Type | Options |
|----------|---------|-------------------|
|ids
|Array of strings | ['id1', 'id2'] |
Example
spotify.album.getAlbums(['4aawyAB9vmqN3uQ7FjRGTy', '1A2GTWGtFfWp7KSQTwWOyo'])
.then(data => {
// do what you want here
})
⇯ go back
album.getTracks(id)
Search for all tracks from a specific album.
Arguments
| Argument | Type | Options |
|----------|---------|-------------------|
|id
|string | 'Specific id'|
Example
spotify.album.getTracks('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want here
})
⇯ go back
Browser Support
This library relies on Fetch API. And this API is supported in the following browsers.
| | | | | --- | --- | --- | --- | --- | 42+ ✔ | 39+ ✔ | 29+ ✔ | 10.1+ ✔ | Nope ✘ |
Dependencies
This library depends on fetch to make requests to the Spotify Web API. For environments that don't support fetch, you'll need to provide a polyfill to browser or polyfill to node.
Testing
To run the tests you can use the following command inside the project folder:
npm test
Or if you want to test the coverage use:
npm run test:coverage
Projects using the library
If you want to submit your application read the CONTRIBUTING.md for more details.
Upcoming methods :)
If you want to help in the project or see the upcoming methods check this link.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
Project License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Authors
| | |:---------------------:| | João Pedro Schmitz |