Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 

UPDATE 2014-02-01: Rdio now has an official Node.js client library, which can be found at https://github.com/rdio/rdio-simple/tree/master/node. The library in this repo is no longer maintained, and is here for archival purposes.


Rdio-Node

Rdio-Node is an Rdio API client library for Node.js. It is based off of the Rdio API Python client (https://github.com/rdio/rdio-python).

How to install

npm install rdio-node

How to use

// Include the library
var Rdio = require('rdio-node').Rdio;

// Create a new instance
var r = new Rdio({
  consumerKey: '<YOUR RDIO KEY>'
, consumerSecret: '<YOUR RDIO SECRET>'
});

// Make an unauthenticated request
r.makeRequest('search', {query: 'Archers of Loaf', types: 'Artist'}, function() {
  console.log(arguments);
});

// Make an authenticated request (with OAuth flow)
r.beginAuthentication(function(error, loginUrl) {
    if (error) {
      console.log(error);
      return;
    }

    var stdin = process.stdin, stdout = process.stdout;
 
    stdin.resume();
    stdout.write('visit: ' + loginUrl + '\nEnter your pin: ');
 
    stdin.once('data', function(data) {
      data = data.toString().trim();
      r.completeAuthentication(data, function() {

        // Notice how unlike the call to 'search' above,
        // 'getPlaylists' doesn't need any parameters.
        r.makeRequest('getPlaylists', function() {
          console.log(arguments[1]);
          process.exit();
        });
      });
    });
  }
);

See the examples/ directory for more examples.

Storing OAuth-related information

The library includes a MemoryStore object that stores OAuth request and access tokens in memory. You can pass in your own datastore object if you wish to store this data elsewhere. Just follow the same interface as MemoryStore, and pass it to the Rdio constructor as the 'dataStore' parameter. Note that the datastore currently does not support async operations (i.e. it doesn't take callbacks), so all loading/saving of data should be done outside the Rdio object.

About

An Rdio API Client Library for Node.js

Resources

Releases

No releases published

Packages

No packages published