It looks like the observation API returns two pieces of data about where an observation was made:
The “place_guess” which is just a string (and could be in any language)
A simple list of “place_ids”, with no organization
If I want to find out, for example, which country an observation was made in, it seems I have to query all of the place IDs in the list (which could be dozens) and see which one has admin_level 0. It would be really nice if the standard place levels were included in the initial observation API response or perhaps as an optional set of data invoked using the ‘extra’ parameter (e.g. ‘extra=places’). The response key pairs could look something like: “continent”: 97394,
“country”: 1,
“admin_level_1”: 42,
“admin_level_2”: 913,
(assuming that admin level -1 is always a continent and admin level 0 is always a country).
For context, this is mainly needed for the iNaturalist2Commons tool, so that it can list where the photo was taken.
Is it actually useful to you to get those place IDs back, or would you actually prefer something more like
"continent": "Asia",
"country": "India"
in the observation search response? If you do want more of that place detail, or you want to consolidate place detail retrieval into one request per batch of observations, what if we added an admin_level param to the places detail endpoint, so your place request could look something like https://api.inaturalist.org/v1/places/1,2,3,4,5,6,7?admin_level=-1,0,1,2?
I’m a little hesitant to add to the observation search responses, which are already kind of like Tetsuo at the end of Akira. @pleary may have thoughts on this too.
@kueda - Sorry for the delayed response. Yes, your suggestion would be a nice improvement and would make dealing with the place data for an observation easier.
@kueda: I am trying to use the admin_level parameter for the places API endpoint to restrict results to certain admin levels. It seems like it’s not working as intended, at least as I understand it.
Your example https://api.inaturalist.org/v1/places/1,2,3,4,5,6,7?admin_level=-1,0,1,2 should be returning 7 results: 6 admin level 1 (states) and 1 admin level 0 (country). Yet, it only returns one result: that for United States (id: 1). No matter how I configure it, I can’t seem to get anything more than countries out (admin level 0) with the admin_level parameter included.
i believe there was a change a while back to make states admin code = 10. similar changes apply to counties and continent admin codes, if i remember correctly.