Pagination
When endpoints might return a large amount of data, the API will return only a subset of that data by returning a Pagination object.
A Pagination object includes the total count
of objects available across all pages, the data
available on this page, and a paging
block which contains instructions for accessing the next/previous pages.
Auto-Pagination
Automated pagination is available in the latest version of the Python and Java libraries. Here’s an example:
# Prints all experiments, one-by-one, by iterating through
# all the required API requests
for experiment in conn.experiments().fetch().iterate_pages():
print(experiment)
# Since iterate_pages() returns an iterator, you may need to turn it into a
# list if you want to do more complicated logic
# list(conn.experiments().fetch().iterate_pages())
Paging manually
If you’d prefer, you can make the API calls to iterate through the pages manually. To receive the next page, call the same endpoint again (with the same parameters), but provide the before
parameter, using the value contained in the paging block. If you want to receive the previous page, use the after
parameter.