Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
disconnect
Advanced tools
disconnect
is a Node.js client library that connects with the Discogs.com API v2.0.
function(err, data, rateLimit)
format for the callbackDiscogs Auth
The global structure of disconnect
looks as follows:
require('disconnect') -> new Client() -> oauth()
-> database()
-> marketplace()
-> user() -> collection()
-> wantlist()
-> util
Here are some basic usage examples that connect with the public API. Error handling has been left out for demonstrational purposes.
var Discogs = require('disconnect').Client;
Get the release data for a release with the id 176126.
var db = new Discogs().database();
db.release(176126, function(err, data){
console.log(data);
});
Set your own custom User-Agent. This is optional as when omitted disconnect
will set a default one with the value DisConnectClient/x.x.x
where x.x.x
is the installed version of disconnect
.
var dis = new Discogs('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 = new Discogs().user().collection();
col.releases('USER_NAME', 0, {page: 2, per_page: 75}, function(err, data){
console.log(data);
});
User, artist and label profiles can be formatted in different ways: plaintext
, html
and discogs
. disconnect
defaults to discogs
, but the output format can be set for each client instance.
// Set the output format to HTML
var dis = new Discogs().setConfig({outputFormat: 'html'});
Just provide the client constructor with your preferred way of authentication.
// Authenticate by user token
var dis = new Discogs({userToken: 'YOUR_USER_TOKEN'});
// Authenticate by consumer key and secret
var dis = new Discogs({
consumerKey: 'YOUR_CONSUMER_KEY',
consumerSecret: 'YOUR_CONSUMER_SECRET'
});
The User-Agent can still be passed for authenticated calls.
var dis = new Discogs('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.
app.get('/authorize', function(req, res){
var oAuth = new Discogs().oauth();
oAuth.getRequestToken(
'YOUR_CONSUMER_KEY',
'YOUR_CONSUMER_SECRET',
'http://your-script-url/callback',
function(err, requestData){
// Persist "requestData" here so that the callback handler can
// access it later after returning from the authorize url
res.redirect(requestData.authorizeUrl);
}
);
});
After redirection to the Discogs authorize URL in step 1, authorize the application.
app.get('/callback', function(req, res){
var oAuth = new Discogs(requestData).oauth();
oAuth.getAccessToken(
req.query.oauth_verifier, // Verification code sent back by Discogs
function(err, accessData){
// Persist "accessData" here for following OAuth calls
res.send('Received access token!');
}
);
});
Simply provide the constructor with the accessData
object persisted in step 3.
app.get('/identity', function(req, res){
var dis = new Discogs(accessData);
dis.identity(function(err, data){
res.send(data);
});
});
Image requests require authentication and are subject to rate limiting.
var db = new Discogs(accessData).database(), file = 'R-176126-1322456477.jpeg';
db.image(file, function(err, data, rateLimit){
// Data contains the raw binary image data
require('fs').writeFile(file, data, 'binary', function(err){
// See your current limits
console.log(rateLimit);
console.log('Image saved!');
});
});
MIT
FAQs
A full-featured Discogs API v2.0 client library
The npm package disconnect receives a total of 188 weekly downloads. As such, disconnect popularity was classified as not popular.
We found that disconnect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.