Reputation: 9
I wanted to see if anyone here has experience using the iNaturalist API because I'm having an issue with it. I built a web page using Python, but I'm not sure if I'm making the request incorrectly or if there's another issue.
Most of the observations I receive in the API response are missing the name of the observation (scientific name). I don't really understand why this is happening. Here’s how I’m making the request:`
import requests
url = "https://api.inaturalist.org/v1/observations"
params = {
"taxon_name": "Plantae",
"lat": 40.7128, # Example latitude
"lng": -74.0060, # Example longitude
"radius": 10, # Search radius in km
"per_page": 50,
"order_by": "observed_on"
}
response = requests.get(url, params=params)
data = response.json()
for obs in data.get("results", []):
taxon = obs.get("taxon", {})
scientific_name = taxon.get("name", "Unknown")
print(f"Scientific Name: {scientific_name}")
Sometimes I get correct scientific names, but in most cases, the "name" field is missing. I’m wondering if I need to change something in my request or if the API just doesn’t always return this data.
Has anyone encountered this issue before? Any advice would be greatly appreciated! Thanks in advance!
Upvotes: 0
Views: 23