Google Books API returns only 10 results

thitami picture thitami · Jul 7, 2012 · Viewed 8.4k times · Source

I am implementing a PHP application that requires some data from Google Books API, for the first time. It is quite awkward, but when I use the typical query http://books.google.com/books/feeds/volumes?q=search+term (someone who has previous experience with the specific API, can understand me), it returns only 10 results.

For instance, the XML response for http://books.google.com/books/feeds/volumes?q=php, contains the following field: totalResults>582. However, I retrieve only 10.

After reading the corresponding documentation, I have not concluded into a solution.

Could anyone help me?

Answer

raina77ow picture raina77ow · Jul 7, 2012

No, its another param: max-results. But it looks like the maximum number of results in one 'page' is still set quite low - at 20.

For example, this query:

http://books.google.com/books/feeds/volumes?q=php&max-results=40

... gave me just 20 entries. It's useful, though, that you can iterate over the collection with start-index param, like this:

http://books.google.com/books/feeds/volumes?q=php&max-results=20&start-index=21

... then 41, 61 etc. It starts with 1, and not 0, I've checked. )