iNat API: Search species occurrences on a set of places

Hi all,

a while ago, I had posted a question on how to find occurrences of a species on different locations by coordinates.
(https://forum.inaturalist.org/t/inat-api-how-to-find-on-which-of-my-locations-a-certain-search-term-has-been-found/30121)

This question is a bit different since from my previous question, I have realized the concept of places on iNaturalist.

Now what I am doing is to search a specific search term for a given set of places on the API with this sample request:
https://api.inaturalist.org/v1/observations?q=cangrejo&place_id=141703,141705

The issue is, that a GET URL length is restricted to a certain length of characters. According to this stackoverflow post, it is around 2000 characters: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

That would mean for my place ids having usually a length of 6 digits, that I would be able to put around 333 place ids into my request.
If I have more places to query, my request would stop working.

So my question is, is there probably a way to
a) request a set of places that contains all my places I would like to query? That would shorten my request URL.
b) send my place ids as a POST request so that the place ids do not end up in the URL’s query parameters but in the request body.

Thanks a lot for any ideas.

as far as i know, the limiting factor is not the number of characters in your URL. when i read the thread you referenced, it looks to me like what they’re saying is that any character limit in the browser would have existed in the past with Internet Explorer, which is a browser hardly anyone uses any more. otherwise, limits are more likely to be enforced by the server and would just depend on how the server is set up.

that said, why do you need to get 333+ place ids into a particular request? are you trying to get details of all those places from /v1/places/{id}, or are you trying to get observations from a set of places from /v1/observations?place_id=[list of places]?

You seem to be correct when you say that what they call “de facto limit” in that post does not necessarily seem to be a restriction in all cases.
I have tested that and could send a request to iNat API with >6000 characters URL length from the Firefox and Chrome address bar and got a prompt response from the iNat server.
However, I have duplicated the place ids in the request to reach this URL length but at least the server does not seem to fend the request off neither seems the browser to complain.

It does not seem to be a very nice way of sending a request to me, but apparently it is working.

About the sense of the request: I am actually only trying to know, on which of my set of places, occurrences of the given species (i.e. search term = parameter q in the query) do exist.
If you know of a better way to achieve that, I would be interested to learn about it. :)

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