rhttrdiscogs-api

Using R to Scrape discogs


I use the following in my attempt to get a list of album release from Hank Mobley, a Blue Note jazz musician:

library(magrittr);library(httr)
releasesHM<-httr::GET("https://api.discogs.com/artists/135872/releases")

This result is error free and I get 15k of data, but I can't seem to identify the content in the 10-item list that results:

Response [https://api.discogs.com/artists/135872/releases]
  Date: 2019-01-09 14:19
  Status: 200
  Content-Type: application/json
  Size: 15.7 kB

discogs says I should have the title and year of each release from this artist. Can anyone offer a solution/guidance?

Thank you!


Solution

  • The output is in JSON, so use package jsonlite to import it:

    library(jsonlite)
    releasesHM <- fromJSON("https://api.discogs.com/artists/135872/releases")
    

    You'll get a list with the data.

    Titles:

    > head(releasesHM$releases$title)
    [1] "The Max Roach Quartet Featuring Hank Mobley"
    [2] "Mobley's Message"                           
    [3] "Jazz Message #2"                            
    [4] "The Jazz Message Of"                        
    [5] "Base On Balls / Stella-Wise"                
    [6] "Lower Stratosphere / Reunion" 
    

    Artists:

    > head(releasesHM$releases$artist)
    [1] "The Max Roach Quartet* Featuring Hank Mobley"                                                                      
    [2] "Hank Mobley"                                                                                                       
    [3] "Hank Mobley"                                                                                                       
    [4] "Donald Byrd, Hank Mobley, Horace Silver, Doug Watkins, John La Porta*, Ronnie Ball, Wendell Marshall, Kenny Clarke"
    [5] "Hank Mobley"                                                                                                       
    [6] "Hank Mobley"