Nuclear Powered Mushroom

    TypeScript icon, indicating that this package has built-in type declarations

    0.7.1 • Public • Published

    Spotify Web SDK

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

    Table of Contents


    "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:


    Using Yarn:

    yarn add spotify-web-sdk

    Using NPM:

    npm install spotify-web-sdk

    Using CDN:

    <script src=""></script>


    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.


    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!


    @JoseRenan and @JRobsonJr

    Hall of Fame

    Made with hall-of-fame.




    npm i spotify-web-sdk

    DownloadsWeekly Downloads






    Unpacked Size

    1.93 MB

    Total Files


    Last publish


    • joserenan
    • jrobsonjr