spotify.js
v0.2.0
Published
Spotify search for the browser and node.
Downloads
8
Readme
Spotify.js: Spotify search in the browser and node.
Spotify search capabilities with the following features:
- Operate in the browser (direct inclusion or requirejs) or node
- Throttle requests as per the Spotify terms of service
- Automatically traverse multi-page results
- 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);
});