Goodreads Developers discussion
help with API method, lack of documentation
date
newest »


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.
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
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

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

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.
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.