Hi,
I’m trying to use the iNat API to fetch data for specific taxa from the IUCN Red List. Unfortunately the IUCN’s IDs are totally different from thos used by iNat. I am not a biologist, and I’m very new to this, so please bear with my naïveté.
Is there a way to “convert” an IUCN taxon ID to a iNat taxon ID ? I wonder how the Red List’s website “knows” the iNat ID for a given species when they fetch images from iNat.
Unfortunately using the API with a taxon name returns too many records.
That’s a good question, I’d also be interested if there’s a good way to do this. Searching by taxon name is the only thing I can think of off the top of my head.
What species did you try searching for with the API that gave you too many results? When searching for a species by name, it seems like the the top result is usually the correct one (although it’s not guaranteed). Narrowing down the search by rank may also help, for example: https://api.inaturalist.org/v1/taxa?q=Quercus%20vulcanica&rank=species
The links above will redirect to the webpage, if you need to process the ids or debug you can add &format=json to the end of the url to get a json object with the ID data
Thank you all for your answers. I’ll get back to you when I have time to try the toolforge and wikidata ways.
In the meantime here’s an example with Calidris pugnax. On the Red List page for this species, we see images from iNat and a link to the corresponding page, inside the “External links and images” section.
For the IUCN this species’ ID is 22693468, but for iNat it’s 339593. The IUCN ‘knows’ this because on the ruff’s page the link to iNat is a well-formatted URL with the correct ID : https://www.inaturalist.org/observations?taxon_id=339593
You can see that from the behavior for Ficus variegata. The API call is https://www.inaturalist.org/observations.json?has[]=photos&limit=20&order=desc&order_by=observed_on&taxon_name=Ficus+variegata&q=Ficus+variegata. This is a problem because iNat has two different taxa with the identical name Ficus variegata and if you give a non-unique name to the parameter taxon_name, it will just return everything. So that parameter does nothing to narrow down the results for this case and instead the call is relying entirely on q=Ficus+variegata, which will search the taxon name, but also the notes, tags, and the place description. It turns out the first result from this API call is an observation with the description “斑叶高山榕Ficus altissima cv. Variegata.” – iNat has this
observation not as Ficus variegata (taxon_id=343952), but as Ficus altissima (taxon_id=162968).
I didn’t know about Wikidata, nor Toolforge. This opens up incredible possibilities. Thanks for pointing this to me.
I ended up using a SPARQL query in Wikidata instead.
I’m writing a short reply to document the solution I found, thanks to @lawnranger’s suggestion.
Using the Toolforge hub as proposed by @lawnranger wasn’t practical for me because I could only get the URL to the iNat page of the species. What I wanted was a way of converting an IUCN id to an iNat id.
I ended up using the following SPARQL query to Wikidata instead: