Search code examples
phpxmlapigoogle-books

Google Books API returns only 10 results


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?


Solution

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

    Edit 2022

    The param is now maxResults not max-results and startIndex not start-index