'Django google books API totalItems is changing

I am creating an application that retrieves data from the google books API. At the very beginning I download a number of books from JSON ["totalItems"] and iterate through the for loop, calling the API in order to get another 40 items. The problem is that the number of books increases and decreases during iteration, so when, for example, on a 550 book, I get a list index out of range error. Anyone please help me download all the books?

My request looks like this:

requests.get(f'https://www.googleapis.com/books/v1/volumes?q={search}\
                &maxResults=40&startIndex={end_range}')

end_range is increased by 40 each time data is downloaded.



Solution 1:[1]

I had a similar problem like you. I used "special keywords" to modify it, and I was able to get the results I wanted. You can find this in API Reference

In ReferenceDocs, you can get hint this code : GET https://www.googleapis.com/books/v1/volumes?q=flowers+inauthor:keyes .

Adding +inauthor:keyes to the q key's value should solve the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1