Is there a iNaturalist API observation output limit?

I want to retrieve all observations from an iNaturalist project and search the observation notes for certain character strings. The idea is to add the URLs to iNaturalist observations and the current ID to a species list with a column that contains unique identifiers that were posted on iNaturalist as a note to the respective observation.

I am using the iNaturalist Python API to do so. However, it seems I cannot find all observations. When I run

from pyinaturalist import *
project_observations = get_observations(project_id = project_ID)
observations = project_observations["results"]

target = []
for obs in observations:from pyinaturalist import *
project_observations = get_observations(project_id = project_ID)
observations = project_observations["results"]

target = []
for obs in observations:
    if obs["description"] is not None and obs["description"] != "":
        if iNaturalist_ID in obs["description"]:
            target.append(obs)
    if obs["description"] is not None and obs["description"] != "":
        if iNaturalist_ID in obs["description"]:
            target.append(obs)

I would expect to find all observations within the project with the ID project_ID and get a list (target) of all observations that contain the identifier iNaturalist_ID in the observation notes. However, a lot of the observations are missing and I noted that len(observations) gives 30 despite the project containing way more than 30 observations.

I suspect the API output is somehow limited to 30 entries? If this is the case, is there a way to change this?

Found out that it returns observations in “pages” with a limit of 30 observations per page. Here is how I solved the problem:

from pyinaturalist import *
observations = []
page_results = [1]
p = 1
while len(page_results) > 0:
    page = get_observations(project_id = project_ID, per_page = 30, page = p)
    page_results = page["results"]
    observations += page_results
    p += 11

in case someone else stumbles upon this.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.