Skip to content
Newer
Older
100644 57 lines (42 sloc) 1.72 KB
4478e24 @monsur Adding Readme
authored
1 # Rdio-Node
2
3 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).
4
5 ## How to install
6
7 npm install rdio-node
8
9 ## How to use
10
11 ```js
12 // Include the library
13 var Rdio = require('rdio-node').Rdio;
14
15 // Create a new instance
16 var r = new Rdio({
17 consumerKey: '<YOUR RDIO KEY>'
18 , consumerSecret: '<YOUR RDIO SECRET>'
19 });
20
21 // Make an unauthenticated request
22 r.makeRequest('search', {query: 'Archers of Loaf', types: 'Artist'}, function() {
23 console.log(arguments);
24 });
25
26 // Make an authenticated request (with OAuth flow)
27 r.beginAuthentication(function(error, loginUrl) {
28 if (error) {
29 console.log(error);
30 return;
31 }
32
33 var stdin = process.stdin, stdout = process.stdout;
34
35 stdin.resume();
36 stdout.write('visit: ' + loginUrl + '\nEnter your pin: ');
37
38 stdin.once('data', function(data) {
39 data = data.toString().trim();
40 r.completeAuthentication(data, function() {
c6cc86d @monsur Added copyrights
authored
41
42 // Notice how unlike the call to 'search' above,
43 // 'getPlaylists' doesn't need any parameters.
4478e24 @monsur Adding Readme
authored
44 r.makeRequest('getPlaylists', function() {
45 console.log(arguments[1]);
46 process.exit();
47 });
48 });
49 });
50 }
51 );
52 ```
53 ## Storing OAuth-related information
54
c6cc86d @monsur Added copyrights
authored
55 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.
4478e24 @monsur Adding Readme
authored
56
Something went wrong with that request. Please try again.