As a vinyl lover and data addict, I had some fun making requests on the Discogs API with R, in order to know better what is inside my library.
Every vinyl lover knows about Discogs. But did you know you could easily access the API? Here are the lines of code I used to access my library.
Note : You can download the data used here in JSON, or directly in R :
Major Tom to Discogs API
Before starting, I’ll need these two functions: _
%>% and ` %||%`._
Let’s first get my Discogs profile:
This first request brings in the environment all the information about a profil (here “_colin”, aka : me).
tells us the number of entries in the library : 308. The
element is the number of “folders” created by the user – 0 corresponding to the whole collection, without any list specification.
Create a dataframe with all the vinyls
The Discogs API sends back pages with 100 max results. Here, my collection has 308, so I’ll use a
loop to query all the data, and store them in a dataframe.
Here is what the dataframe looks like:
Table continues below
||Night And Day
||A&M Records (2)
||God Save The Queen
||Alexi Delano Limited
||The Acid Sessions Vol. 4
||Urban Minds / Skattered
||And The Dead Shall Lie There
I can’t see, I can’t see I’m going blind
And now, let’s start visualising!
Most frequent labels
Philips and Polydor, what a surprise!
Most frequent artists
So… here’s the big revelation: I love Serge Gainsbourg and Geogres Brassens (guilty pleasure).
Looks like I’m not a big 90’s fan! My library show a bimodal distribution, with one mode around the 80’s, and one around 2005.
It’s time to go deeper
So, can we get more information about this library?
Hello, it’s me again
_Note: between the writing of this blogpost and now, Discogs seems to have put a rate limit on its API. For the creation of
collection_2, you should consider using
Sys.sleep(). More on that here.
Here, I have used the release_id element to make a request about each vinyl.
Most frequent genre
OH GOD, what a surprise! Almost half of my collection is made of rock albums (who could have guessed?).
Thanks a lot Discogs! It looks like I’ve got quite good musical tastes (thanks for the ego boost :) !)
Prices of vinyls (low range)
Ok, I’m not gonna be rich selling my vinyl collection…
Relationship between price and “want”
Here, we can see a correlation between the price and the number of users that put a “want” on a particular vinyl.
Price and average note
Here, no significative correlation.
And to conclude…
Next step… create a package to access the Discogs API? Why not! Let’s put this on my to-do…