python - iNaturalist API – Missing observation names in response? - Stack Overflow

I wanted to see if anyone here has experience using the iNaturalist API because I'm having an issu

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 = ";
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!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745265600a4619434.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信