API taxon search doesn't respect tautonyms

Platform: Web

App version number, if a mobile app issue:

Browser, if a website issue:

URLs (aka web addresses) of any relevant observations or pages:
For Pica pica (Eurasian Magpie):

https://api.inaturalist.org/v1/taxa?q=Pica+pica&is_active=true&per_page=1

Returns:
“default_photo”: {
“id”: 2964195,
“license_code”: “cc-by-nc”,

But that picture is a toucan:
https://inaturalist-open-data.s3.amazonaws.com/photos/2964195/medium.jpg

https://inaturalist-open-data.s3.amazonaws.com/photos/2964195/medium.jpg

Screenshots of what you are seeing:

Description of problem:

API request for default photo of Eurasian Magpie returns url for the image of a Toucan.

I don’t think this is a bug, you searched for a taxon got 759 results and the first one happens to Order Piciformes (from “Tucanos, Pica-Paus e afins”), and this is the correct photo for that taxon. I think for your purposes you want to find an exact match for “Pica pica” (maybe that is a filter you can include that in the url or something?), but anyway I would suggest using the taxon ID (891696) since that is less likely to be misinterpreted.

For example: https://api.inaturalist.org/v1/taxa?id=891696

Platform: Web

App version number, if a mobile app issue:

Browser, if a website issue: Any

URLs (aka web addresses) of any relevant observations or pages:

https://api.inaturalist.org/v1/taxa?q=Riparia+riparia&is_active=true&per_page=1

Screenshots of what you are seeing:

Description of problem:

Step 1: Visit “https://api.inaturalist.org/v1/taxa?q=Riparia+riparia&is_active=true&per_page=1

Step 2: Use returned json to extract the default photo id: 78038371

Step 3: Use default photo id to generate this url: “https://inaturalist-open-data.s3.amazonaws.com/photos/78038371/medium.jpg

Result: The returned image is the seed head of a grass species:

https://inaturalist-open-data.s3.amazonaws.com/photos/78038371/medium.jpg

I merged your reports and changed the title to reflect the shared cause of both of them. When you search for a name that has the same genus and species epithet (a tautonym), the API doesn’t process it as a true genus and species combination. This is a known issue that is already documented on github: https://github.com/inaturalist/iNaturalistAPI/issues/605

As isopod-fan said, the pica search is hitting on the Portuguese name of https://www.inaturalist.org/taxa/17550-Piciformes, and the riparia search is hitting on an unaccepted scientific name of https://www.inaturalist.org/taxa/63337-Phalaris-arundinacea. Search by taxon id is the current workaround.

I think it is the logic in the search query that is to blame here, when you search for “Pica+pica” the search returns results that include Pica and/or pica (anywhere in the name). Since the case probably isn’t taken into account it is really just looking for results that have Pica/pica and/or Pica/pica in them, so it sees “Tucanos, Pica-Paus e afins”, and Pica/pica is present, as is Pica/pica, so that is as good as it gets, along with the other 759 results that have Pica/pica in them. Then I assume it sorts by popularity or number of observations, so Piciformes is returned as the top result.

If you want this to work then I assume you will need to have the whole query “Pica pica” (including the space) taken into account rather than just the individual words.

Note that even if they searched for “Pica+pica”, it would still just be a prefix search, not an exact string search. The iNaturalist API doesn’t support exact string searches: https://github.com/inaturalist/iNaturalistAPI/issues/336.

Thanks for the clarifications!