Goodreads Developers discussion

149 views
examples / showcase > Integration Issues

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

message 1: by Prakhar (last edited Dec 23, 2015 06:47AM) (new)

Prakhar | 5 comments Hi there,

I am developing a web based application for my client where end user would be able to input ISBN / Title / Author and we would provide him the search results.

I checked your APIs and found that "search.books" should do the trick. So, I started experimenting around it and found a few stumble blocks. I have already created my developer account and have the API Keys with me. It would be great if you could guide me through these issues.

1. The api "https://www.goodreads.com/search/inde..." only provides an XML response. Do we have an equivalent of the API in JSON format or any Restful resource.

2. The query breaks and gives 403 : forbidden error when there are spaces in the search parameter. Could you please confirm if i need to replace all my spaces with "_", because that seem to work from my local environment for now.

3. Is there a limit on the number of requests i can make everyday? I have read that you allow only one request per second and we are going to honor that.

4. Somehow, the response for the search.books api is extremely slow. I use PHP curl to get the results. I have a high speed connection in my development machine and I am expecting this to be pretty quick. Could you suggest any workarounds for this. The endpoint opens immediately if I type it on the browser window but its takes around 10-15 seconds through the curl-PHP.

Please check below the code that I use. (Development only)


$key = "MY_API_KEY";
$url = "http://www.goodreads.com/search/index...

$query = ($_GET['q']);
$effective_url = $url.$query;
$effective_url = str_replace( "&", "&", urldecode(trim($effective_url)) );

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $effective_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
if ($output === false)
{
echo "Curl Error Number:" . curl_errno($ch) . "
";
echo "Curl Error String:" . curl_error($ch);
}
else
{
echo ($output);
}
curl_close($ch);


And I call this endpoint like : http://localhost/application_name/tes...


message 2: by Charles (new)

Charles Kim | 28 comments Hi Prakhar,

1) We only provide XML responses.

2) If you're experiencing issues with spaces, you could try formatting the url as in the following example: https://www.goodreads.com/search/inde...

3) The Developer Terms of Service stipulates that you not request any method more than once a second.

4) The response times seem about the same from here with curl and a browser. It may be the way curl is trying to resolve the URL vs the browser. I would suggest searching online for possible solutions. Here's a question on StackOverflow that may be relevant to your situation: http://stackoverflow.com/questions/36...

Thanks for contacting us!


message 3: by Prakhar (new)

Prakhar | 5 comments Hi Charles,

Thanks for the information.

1) OK
2) Thanks, all the white spaces have to be replaced with "+". Hope someone else finds it useful.
3) Sure, we will honor that from our end.
4) Yes, I figured out that the actual response time from your servers was always under a second. It was the way in which my machine does the reverse DNS lookup which caused the problem. For reference to others I had to inform curl to treat this as IPv4 type DNS/IP . I added below code in PHP which drastically reduced the overall time by around 12 secs for me.
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );


back to top