I’ve written a little taxon lookup command for the iNat unofficial Discord & I’m trying to figure out what to do with names that are matched in the API /v1/taxa?q= that aren’t actually present in the results. Here’s an issue on the code I’m writing concerning my problem:
To sum that up, I sometimes get back results that may contain a matched_term value that bears little relation to whatever was in the query. If you go to the web page and click the Taxonomy tab you can find the names that matched (but I don’t want the overhead of displaying the whole web page and the tedious job of scraping those names off the page, so I’m not going to do that).
If I simply don’t tell the user what matched and show them that result anyway, it is going to look broken.
I don’t want to just discard the result, either, as it might be what they actually know the taxon by (i.e. a name other than the “preferred common name”).
Ideally, I’d like to tell the user the name that their query matched so that the response is intelligible to them.
Since matched_term isn’t reliable (see my “common teal” example in the linked bug report above), what am I to do? I’m tempted to use the taxon_names.json endpoint the web page calls, since that would be a heck of a lot easier than scraping the whole web page! Is this kosher? It’s not in a published API, so I understand there’s a risk it might change tomorrow and then my code would no longer work.