Goodreads Developers discussion

292 views
help with API method, lack of documentation

Comments Showing 1-5 of 5 (5 new)    post a comment »
dateUp arrow    newest »

message 1: by John (last edited May 14, 2017 12:13PM) (new)

John (johnbdonner) | 4 comments My name is John and I've been exploring your guys' API for a bit. I can't seem to find documentation on a method that I'm able to call on a book, called `language_code`.

This method seems to return the language of the edition of the book. For example, I retrieve a data object of the book "Meditations" and calling `meditations.language_code` returns `"eng"`. Nice! However, when I call the same method on a different book, such as "The Lean Startup", it returns `"en-US"`.

Is there any official documentation or usage that I'm not seeing? I'd like to be able to retrieve this information for each book.


message 2: by Kemory (new)

Kemory Grubb | 8 comments It's very unlikely you get an answer saying that they will make the needed corrections to the API. You will have to work around this issue.

Your best option here is to create an array of possible values for 'language_code'. The when you get your response from the API check to see if the API value is in the array. If is is in the array you can assume and normalize the value.

Eg.
$eng_lang = ['eng', 'en-US', 'en', 'English']
$api_result = meditations.language_code
if ( in_array( $api_result, $api_result ) ) { $book_lang = 'English' }

Then use $book_lang however you want to.


message 3: by Marco (new)

Marco Pavan (revenue) | 6 comments Mod
Hi John,

the language code you are getting back is an attribute of the book record the API is returning back to you. it likely depends on the book id you request from the API. i checked several book id for the lean startup and i got back "eng". if you are getting "en-US" for a specific book id, there might be a problem with the data regarding that specific book record as language_code should be stored in iso639_2 format. Can you please let me know what the specific book ids for the two books mentioned above?

thanks


message 4: by John (last edited May 17, 2017 02:12PM) (new)

John (johnbdonner) | 4 comments Thank you Kemory for the response, that would be a good way to get around the issue. Although I was hoping to get info about a standard that might be implemented.

Marco, thank you for getting back to me and letting me know about the iso639_2 format. And sure:

book id for "Meditations" was: 30659
book id for "The Lean Startup: How Today's Entrepreneurs Use Continuous Innovation to Create Radically Successful Businesses" was: 10127019


message 5: by John (new)

John (johnbdonner) | 4 comments Marco wrote: "Hi John,

the language code you are getting back is an attribute of the book record the API is returning back to you. it likely depends on the book id you request from the API. i checked several bo..."


Also Marco, it seems that there isn't even a `language_code` available for the book "UX for Lean Startups" (id: 16128986), as it's attribute is set to `nil`. So I see that this really depends on what book is returned.


back to top