spotify.js

0.2.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i spotify.js

Weekly Downloads

17

Version

0.2.0

License

BSD

Last publish

Collaborators

  • gyllstromk