npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-spotify-wrapper

v3.0.7

Published

A small and awesome wrapper to get general information from the Spotify Web API.

Downloads

19

Readme

Simple Spotify Wrapper

Build Status Coverage Status

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 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.

Chrome | Firefox | Opera | Safari | IE | --- | --- | --- | --- | --- | 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| |:---------------------:| | João Pedro Schmitz |