Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TooTallNate/node-spotify-web
Node.js implementation of the Spotify Web protocol
https://github.com/TooTallNate/node-spotify-web
Last synced: 18 days ago
JSON representation
Node.js implementation of the Spotify Web protocol
- Host: GitHub
- URL: https://github.com/TooTallNate/node-spotify-web
- Owner: TooTallNate
- License: mit
- Created: 2013-01-05T06:06:40.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-01-12T07:20:59.000Z (almost 8 years ago)
- Last Synced: 2024-10-24T02:45:49.381Z (21 days ago)
- Language: JavaScript
- Homepage:
- Size: 1.19 MB
- Stars: 696
- Watchers: 56
- Forks: 128
- Open Issues: 47
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
node-spotify-web
================
### Node.js implementation of the Spotify Web protocolThis module implements the "Spotify Web" WebSocket protocol that is used on
Spotify's [Web UI](http://play.spotify.com).This module is heavily inspired by the original open-source Python implementation:
[Hexxeh/spotify-websocket-api](https://github.com/Hexxeh/spotify-websocket-api).Installation
------------``` bash
$ npm install spotify-web
```Example
-------Here's an example of logging in to the Spotify server and creating a session. Then
requesting the metadata for a given track URI, and playing the track audio file
through the speakers:``` javascript
var lame = require('lame');
var Speaker = require('speaker');
var Spotify = require('spotify-web');
var uri = process.argv[2] || 'spotify:track:6tdp8sdXrXlPV6AZZN2PE8';// Spotify credentials...
var username = process.env.USERNAME;
var password = process.env.PASSWORD;Spotify.login(username, password, function (err, spotify) {
if (err) throw err;// first get a "Track" instance from the track URI
spotify.get(uri, function (err, track) {
if (err) throw err;
console.log('Playing: %s - %s', track.artist[0].name, track.name);// play() returns a readable stream of MP3 audio data
track.play()
.pipe(new lame.Decoder())
.pipe(new Speaker())
.on('finish', function () {
spotify.disconnect();
});});
});
```See the `example` directory for some more example code.
API
---TODO: document!
License
-------(The MIT License)
Copyright (c) 2013-2014 Nathan Rajlich <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.