A full featured Discogs API v2.0 client library
function(err, data, rateLimit)format for the callback or return a native JS Promise when no callback is provided
The global structure of
disconnect looks as follows:
require('disconnect') -> new Client() -> oauth()-> database()-> marketplace()-> user() -> collection()-> wantlist()-> list()-> util
Here are some basic usage examples that connect with the public API. Error handling has been left out for demonstrational purposes.
var Discogs = Client;
Get the release data for a release with the id 176126.
var db = ;db;
Set your own custom User-Agent. This is optional as when omitted
disconnect will set a default one with the value
x.x.x is the installed version of
var dis = 'MyUserAgent/1.0';
Get page 2 of USER_NAME's public collection showing 75 releases. The second param is the collection folder ID where 0 is always the "All" folder.
var col = ;col;
When no callback is provided, the API functions return a native JS Promise for easy chaining.
var db = ;db;
User, artist and label profiles can be formatted in different ways:
disconnect defaults to
discogs, but the output format can be set for each client instance.
// Set the output format to HTMLvar dis = ;
Just provide the client constructor with your preferred way of authentication.
// Authenticate by user tokenvar dis = userToken: 'YOUR_USER_TOKEN';// Authenticate by consumer key and secretvar dis =consumerKey: 'YOUR_CONSUMER_KEY'consumerSecret: 'YOUR_CONSUMER_SECRET';
The User-Agent can still be passed for authenticated calls.
var dis = 'MyUserAgent/1.0' userToken: 'YOUR_USER_TOKEN';
Below are the steps that involve getting a valid OAuth access token from Discogs. Note that in the following examples the
app variable is an Express instance to handle incoming HTTP requests.
After redirection to the Discogs authorize URL in step 1, authorize the application.
Simply provide the constructor with the
accessData object persisted in step 3.
Image requests themselves don't require authentication, but obtaining the image URLs through, for example, release data does.
var db = accessData;db;