"Convert" IUCN taxon ID to iNat ID?

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.

Thank you very much in advance for your help,

Pierre.

5 Likes

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

Also ,this taxon scheme may be of interest, although it’s likely not up to date: https://www.inaturalist.org/taxon_schemes/14

2 Likes

Can you give a real world example of a species you are trying to do this for.

The iucn red list site very likely knows the inat Id for a particular taxon by querying Wikidata where both will be stored.

3 Likes

If the taxon IDs are up to date on wikidata you can use the Toolforge Hub to ‘convert’ from IUCN ID to iNat ID.

general format:
https://hub.toolforge.org/[IUCN taxon property id]:[IUCN taxon ID]?property=[iNaturalist taxon property ID]
eg. Panthera leo (Lion): https://hub.toolforge.org/P627:15951?property=P3151
P627 - IUCN taxon property id
15951 - IUCN taxon ID for Lion
P3151 - iNaturalist taxon property ID

For some reason the reverse does not work:
eg. https://hub.toolforge.org/P3151:41964?property=P627
41964 - iNat taxon ID for Lion

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

4 Likes

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

1 Like

IUCN makes a call to the iNat API with the name of the taxon, e.g. https://www.inaturalist.org/observations.json?has[]=photos&limit=20&order=desc&order_by=observed_on&taxon_name=Calidris+pugnax&q=Calidris+pugnax.
It uses this to return the photos, but it also sets the link out to iNat using the taxon_id from the first returned result.

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).

And the link out to iNat uses this incorrect F. altissima ID.

So IUCN isn’t storing the taxon_id anywhere, it’s just looking it up by name via iNat’s API at the time you load the images.

3 Likes

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.

1 Like

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:

SELECT ?animal ?animalLabel ?iucncode ?inatcode WHERE {
        VALUES ?iucncode { "15951" }
    ?animal wdt:P627 ?iucncode;
        wdt:P3151 ?inatcode.
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
    }

You can try the query here

I needed to do that for many species so I made a Python script based on this query.

3 Likes

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