Skip to content
Spotify search for the browser and node.
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
.jshintignore
.npmignore
.travis.yml
LICENSE
README.md
bower.json bump version
package.json bump version
spotify.js Merge pull request #3 from tusbar/urlencode

README.md

Spotify.js: Spotify search in the browser and node.

Build Status

Install via npm (node) or bower (browser):

$ npm install spotify.js
$ bower install spotify

Spotify search capabilities with the following features:

  1. Operate in the browser (direct inclusion or requirejs) or node
  2. Throttle requests as per the Spotify terms of service
  3. Automatically traverse multi-page results
  4. Tested.
spotify.artists('pixies', function(err, artists) {
    console.log('Artists results:', artists);

    spotify.albums('Doolittle', function(err, albums) {
        console.log('Album results:', albums);

        spotify.tracks('Debaser', function(err, tracks) {
            console.log('Track results:', tracks);
        });
    });
});

// Or, stream results as they arrive ...

spotify.tracks('love').forEach(function(track) {
    if (track === null) {
        // finished
    } else {
        console.log('Track result:', track);
    }
});

Getting started (browser)

Use with either requirejs or raw include.

Requirejs

jQuery is required, so use the require-jquery approach:

<script data-main="/path/to/spotify.js" src="/path/to/require-jquery.js"></script>
<script>
  require(['spotify'], function(spotify) {
    spotify.albums('doolittle', function(err, albums) {
       console.log(albums);
    });
  });
</script>

Simple script include (requires jQuery)

<script src="jquery.min.js" type="text/javascript"></script>
<script src="/path/to/spotify.js" type="text/javascript"></script>
<script type="text/javascript">
    spotify.albums('doolittle', function(err, albums) {
       console.log(albums);
    });
</script>

Node

var spotify = require('spotify.js');

spotify.albums(query, function(err, albums) {
    console.log(albums);
});

Contributers

  • @gyllstromk
  • @tusbar
Something went wrong with that request. Please try again.