pyinaturalist.pagination module

pyinaturalist.pagination.add_paginate_all(method='page')[source]

Decorator that adds auto-pagination support, invoked by passing page='all' to the wrapped API function.

Parameters

method (str) –

pyinaturalist.pagination.estimate_request_size(total_results)[source]

Log the estimated total number of requests and rate-limiting delay, and show a warning if the request is too large

pyinaturalist.pagination.paginate_all(api_func, *args, method='page', **params)[source]

Get all pages of a multi-page request. Explicit pagination parameters will be overridden.

Parameters
  • api_func (Callable) – API endpoint function to paginate

  • method (str) – Pagination method; either ‘page’, ‘id’, or ‘autocomplete’ (see below)

  • params – Original request parameters

Return type

Dict[str, Any]

Note on pagination by ID, from the iNaturalist documentation: _’The large size of the observations index prevents us from supporting the page parameter when retrieving records from large result sets. If you need to retrieve large numbers of records, use the per_page and id_above or id_below parameters instead.’_

Return type

Dict[str, Any]

Returns

Response dict containing combined results, in the same format as api_func

Parameters
  • api_func (Callable) –

  • method (str) –

pyinaturalist.pagination.paginate_autocomplete(api_func, *args, **params)[source]

Attempt to get as many results as possible from the places autocomplete endpoint. This is necessary for some problematic places for which there are many matches but not ranked with the desired match(es) first.

This works based on different rankings being returned for order_by=area. No other fields can be sorted on, and direction can’t be specified, but this can at least provide a few additional results beyond the limit of 20.

Return type

Dict[str, Any]

Parameters

api_func (Callable) –