Closed willgearty closed 8 months ago
PhyloPic makes parallel calls to a number of external databases (EoL, GBIF, OTOL, PBDB) -- it's fairly complex and asynchronous. The details are in here: https://github.com/keesey/phylopic/tree/main/packages/ui/src/search
This is done client-side rather than server-side to keep PhyloPic's operating costs down.
I forgot, I did document the general approach here: https://www.phylopic.org/articles/api-recipes#searching-name
Note that there's some kind of bug on that page right now where it's inserting build=NaN
into the queries. I need to fix that for the "play" buttons to work. But the documentation should still be useful.
I believe there are R packages that interface with all of those databases, although it might just be easier for us to query their APIs ourselves instead of depending on those extra packages.
Either way you'll still have to use the "Resolve Node" examples in the link above to translate results into the closest PhyloPic nodes.
Plan:
resolve_phylopic(name, api = "paleobiodb.org", hierarchy = FALSE, n = 1)
name
: the taxonomic name that should be searched in the external api (see here: https://www.phylopic.org/articles/api-recipes#searching-name)api
: the name of the external api/website (looks like phylopic supports quite a few, see the /namespaces endpoint)hierarchy
: should the return be a single UUID (for the closest match from /resolve) or should we return a list (with a UUID for each taxonomic rank returned by the api)n
: the number of UUIDs to be returned (per rank if hierarchy = TRUE
)Some notes:
n>1
we will need to get the image UUIDs on our ownI've started this on the resolve_phylopic
branch
The goal for
get_uuid
is to make it behave just like the search bar on phylopic.org. However, it appears that we are still missing something, because some search terms give errors withget_uuid
whereas they give reasonable results on phylopic.org. It looks like this might be related to phylopic's use of external databases, which maybe we could emulate using some of the phylopic API endpoints? Or maybe we should reach out to Mike and see if thesearch
endpoint could better emulate the frontend search functionality?Here's an example that works on phylopic.org but not with
get_uuid
: Myotis lucifugus