node-soundcloud
node.js wrapper for the Soundcloud SDK. Inspired by the libraries soundcloud-node and soundclouder.js.
Getting started
npm install --save node-soundcloud
var SC = require('node-soundcloud')
Getting an OAuth Token
- Require
node-soundcloud
and initialize with your parameters - Redirect user to the necessary SoundCloud Connect URL
- User will then be redirected to your
redirect_uri
, which can be handled by an Express endpoint (discussed in the next section).
var SC = ; // Initialize clientSC; // Connect user to authorize applicationvar { var url = SC; res; res;}; // Get OAuth token (example endpoint discussed in the next section)
Example Redirect URI Endpoint
After your user is redirected to the Connect URL, SoundCloud will then redirect them back to the URL you have specified as your redirect_uri
. There will also be the parameter code
in the query string, and this is used to retrieve your OAuth token. An endpoint to handle this could work as follows:
var { var code = reqquerycode; SC;};
Initializing with an OAuth Token
If you have already acquired an OAuth access token, you can initialize the client without going through the authorization process by passing it as an extra option:
var SC = ; // Initialize client with additional accessToken fieldSC;
Making calls to the SoundCloud API
Once authorized (or if you're accessing unprotected endpoints), you may now make calls to the SoundCloud API documented here. An example could be as follows:
SC;