Some API methods may return very large lists of data.
To reduce the response size, many of these API methods support pagination.
With paginated results, your application can iteratively request
and process large lists one page at a time.
For API methods that support it,
there exists similarly named methods with a "_next" suffix.
For example, if a method is named
there may also be a method named
These methods can be found in the API's PyDoc documentation on the
Supported APIs page.
To process the first page of results,
create a request object and call
execute() as you normally would.
For further pages,
you call the corresponding
and pass it the previous request and response.
Continue paging until
In the following code snippet,
the paginated results of a Google Plus activities
list() method are processed:
activities = service.activities() request = activities.list(userId='someUserId', collection='public') while request is not None: activities_doc = request.execute(http=http) # Do something with the activities request = activities.list_next(request, activities_doc)
Note that you only call
execute() on the request once inside the while loop.