-
Notifications
You must be signed in to change notification settings - Fork 30
Connecting to Discogs
Discogs is a website and crowdsourced database of information about audio recordings, including commercial releases, promotional releases, and bootleg or off-label releases.
You will need to add the ruby-rdf/linkeddata gem that processes a large number of linked data serializations. The Discogs API returns JSON, not linked data. However, the Discogs Authority provides the option of converting the Discogs data to JSON-LD, and this process requires serialization.
gem 'linkeddata'
You need to register for a Discogs account, which is explained on the Discogs authentication page. Create an application to receive a Consumer Key and Secret. Once you have those, you can run queries like this:
https://api.discogs.com/database/search?q=sinatra&type=release&key=CONSUMER_KEY&secret=CONSUMER_SECRET
You should see about 10 results for this URL.
Run this command to install the configuration files:
rails generate qa:discogs
Put the following statements in an initializer and restart the rails server.
Qa::Authorities::Discogs.discogs_key = 'CONSUMER_KEY'
Qa::Authorities::Discogs.discogs_secret = 'CONSUMER_SECRET'
Authority: | geonames |
---|
Subauthorities:
- master
- release
NOTE: If no subauthority is specified, then all records that match the query term are returned.
/qa/search/discogs/release?q=sinatra+the+modernaires
Result:
[
{
"uri": "/Frank-Sinatra-And-The-Modernaires-Sorry-Why-Remind-Me/master/1177655",
"id": "1177655",
"label": "Frank Sinatra And The Modernaires - Sorry / Why Remind Me",
"context": {
"Image URL": [
"https://img.discogs.com/2e-YoNr0dvmMgbzEN0hjHD6X0sU=/fit-in/600x580/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-4212473-1358693671-5430.jpeg.jpg"
],
"Year": [
"1950"
],
"Record Labels": [
"Columbia"
],
"Formats": [
"Shellac",
"10\"",
"78 RPM"
],
"Type": [
"master"
]
}
},
etc.
]
NOTE: The qa request is converted to the following Discogs request. This is for information only. You do not need to know this to use QA.
https://api.discogs.com/database/search?q=sinatra+the+modernaires&type=release&key=dummy_key&secret=dummy_secret
When the format is JSON, Discogs data is returned without being altered. When the format is JSON-LD, the translation module converts the Discogs data into linked data relationships and maps Discogs terms to their corresponding BIBFRAME properties.
/qa/show/discogs/release/3380671
Result:
{ "status": "Accepted", "labels": [ { "name": "Blue Note" } ], "year": 1962, "artists": [ { "name": "Dexter Gordon" } ], "id": 3380671, "genres": [ "Jazz" ], "title": "A Swingin' Affair", "styles": [ "Hard Bop" ], "formats": [ { "qty": "1", "descriptions": [ "LP", "Album", "Mono" ], "name": "Vinyl" } ], etc. } NOTE: The qa request is converted to the following Discogs request. This is for information only. You do not need to know this to use QA.
https://api.discogs.com/releases/3380671
/qa/show/discogs/master/950011?format=jsonld
Result:
{ "genres": [ "Jazz" ], "title": "Blue Moon / You Go To My Head", "year": 1952, "uri": "https://www.discogs.com/Billie-Holiday-And-Her-Orchestra-Blue-Moon-You-Go-To-My-Head/master/950011", "tracklist": [ { "duration": "", "position": "A", "type_": "track", "extraartists": [ { "join": "", "name": "Rodgers & Hart", "anv": "", "tracks": "", "role": "Written-By", "resource_url": "https://api.discogs.com/artists/604171", "id": 604171 } ], "title": "Blue Moon" }, { "duration": "", "position": "AA", "type_": "track", "extraartists": [ { "join": "", "name": "Haven Gillespie", "anv": "Gillespie", "tracks": "", "role": "Written-By", "resource_url": "https://api.discogs.com/artists/583502", "id": 583502 }, { "join": "", "name": "J. Fred Coots", "anv": "Coots", "tracks": "", "role": "Written-By", "resource_url": "https://api.discogs.com/artists/583506", "id": 583506 } ], "title": "You Go To My Head" } ], etc. } NOTE: The qa request is converted to the following Discogs request. This is for information only. You do not need to know this to use QA.
https://api.discogs.com/masters/950011
Not supported
$('input#discogs').autocomplete({
minLength: 3,
source: function(request, response) {
$.ajax({
url: '/qa/search/discogs/release',
type: 'GET',
dataType: 'json',
data: {
q: request.term,
},
complete: function(xhr, status) {
var results = $.parseJSON(xhr.responseText);
if ( results.length > 0 ) {
response(results);
}
}
});
},
select: function(event, ui) {
$.ajax({
url: '/qa/show/discogs/' + ui.item.id,
type: 'GET',
data: {
format: 'jsonld',
subauthority: ui.item.context.Type[0]
},
dataType: 'json',
complete: function(xhr, status) {
var results = $.parseJSON(xhr.responseText);
[ your function for rendering the results ]
}
});
}
});
Discogs documents their API at... https://www.discogs.com/developers/
Using Questioning Authority
- Connecting to Discogs
- Connecting to GeoNames
- Connecting to Getty
- Connecting to Library of Congress (LOC)
- Connecting to Medical Subject Headings (MeSH)
- Connecting to OCLC FAST
Custom Controlled Vocabularies
Linked Data Access to Authorities
- Connecting to Linked Data authorities
- Using the Linked Data module to access authorities
- Configuring access to a Linked Data authority
- Language processing in Linked Data authorities
Contributing to Questioning Authority
- Contributing a new external authority
- Template for authority documentation
- Understanding Existing Authorities