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

spotify-web-sdk

v0.7.2

Published

A JavaScript SDK for the [Spotify Web API](https://developer.spotify.com/documentation/web-api/). Note that this project is still a BETA version.

Downloads

148

Readme

Spotify Web SDK

A JavaScript SDK for the Spotify Web API. Note that this project is still a BETA version.

Table of Contents

Features

"Why should I use this?"

We want to handle the hard work for you. Even to make simple requests, such as to get information on a track, you'd need to make a bunch of setups. Here is how you could do the same thing with our aid:

import * as spotify from 'spotify-web-sdk';
spotify.init({ token: 'YOUR SPOTIFY TOKEN HERE!' }); // You should only need to run this once.
spotify.getTrack('3LOpHuEpjkL4T1Zcjhko8w'); // Or any other track id.

Yes, it's as simple as that!

"I still think it's no hard work at all. Therefore, I don't see the point in using this."

How rude! As you might have noticed, this is an open source project, which means that you can add or suggest your own features. Of course, don't expect us to ever have a method such as getTaylorSwiftBestTracks pushed into our master branch. (But if you ever thought on something like that, hey, let's be friends!)

What we really mean is: there's a lot of information that can be extracted from the data retrievable via Spotify's Web API. If you think of something that could come in handy for you and also other people, that's it! Don't be shy, make it happen. We'll gladly review your suggestion as soon as possible!

For instance, you can retrieve the duration of a track in milliseconds straight from the API, but know what'd more usual? If you thought "displaying it in minutes", we're on the same page. To do that, adding the following code to our Track model would do the trick:

get formattedDuration() {
    const minutes = Math.floor(this.durationMs / 60000);
    const seconds = Math.floor((this.durationMs % 60000) / 1000);
    return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
}

This is already implemented, but do you get our point? It might be something really simple, but we believe that such little things can save a lot of time in the future.

"You convinced me. Let's go!"

Even though I'm not certain you thought that right now, here's how to get started:

Installation

Using Yarn:

yarn add spotify-web-sdk

Using NPM:

npm install spotify-web-sdk

Using CDN:

<script src="https://unpkg.com/spotify-web-sdk/build/dist/spotify-web-sdk.min.js"></script>

Usage

First of all, you will need a Spotify authorization token. For that, check Spotify Web API's Authorization Guide. Please note that you might need some specific authorization scopes depending on the requests you'll be running.

And then you'll only need to import the function that implements the request you want to make. Remember that you'll need to run the init function passing your authorization token to authorize making the requests. There's an example of the usage at the beginning of this README.

Community

As aforementioned, this project exists because we believe that we can support each other to create a better experience for everyone. You can contribute in many ways. Please, note that we have a Code of Conduct, which we expect to be strictly respected.

Suggest a new feature or report a bug

If you notice any other bugs or you have any ideas to improve our SDK, feel free to create an issue. We'll be more than happy to discuss it! Check our issue templates.

Do it yourself

Check out our CONTRIBUTING file!

Maintainers

@JoseRenan and @JRobsonJr

Hall of Fame

Made with hall-of-fame.

License

MIT