{{response.title=base_title + ': ' + T('tree APIs')}} {{response.files.append(URL('static', 'css/content_pages.css'))}} {{ def link(a, **kwargs): # Just saves us having to re-write the actual URL twice return A(a, _href=a, **kwargs) pass }} {{block masthead}}
{{=XML(T('Several mappings used by the OneZoom Tree of Life Explorer may be useful for other purposes, and are made available via public APIs. These APIs all require an OTT ID to be passed in (e.g. the OTT ID for Homo sapiens is 770315, for mammals it is 244265). You can obtain OTT IDs for scientific names through the Open Tree of Life TNRS service.'))}}
{{=XML(T('Note that APIs only return results that are on the OneZoom Tree of Life. For example, we do not normally include subspecies, such as Canis lupus familiaris (the domestic dog) on the OneZoom tree: only the full species, Canis lupus (the grey wolf, including the domestic dog, dingo, Indian wolf, etc.), are displayed on the tree and returned using from OneZoom APIs. Although there is an Open Tree identifier for Canis lupus familiaris, it will not be recognised if passed to this API. Additionally, OneZoom does not store higher level names for monospecific taxa, i.e. for a species like the tuatara, Sphenodon punctatus, the OTT for the species (35890) will be recognised, but searching for the genus Sphenodon (OTT 35886) will not return any results, nor will the higher level monospecific order Rhynchocephalia (OTT 35876). In a similar vein, where multiple taxonomic names describe the same set of species on the OneZoom tree, only the highest distinguishing level is used. For example, lancelets are classified in OneZoom as Cephalochordata (OTT 176555): the lower level family Branchiostomidae (OTT 176551), in which all living cephalochordates also fall, is not recognised in OneZoom or in this API.'))}}
{{=T('Public APIs are available which, for a given set of Open Tree Taxonomy (OTT) identifiers, return:')}}
representative imagesfor higher level taxa'))}}
phylogenetically informed popularity indexfor all taxa, which is documented on a separate page') % {'slot0': (xmlescape(URL(c='popularity')))})}}
key=MY_API_KEY {{=T('to the URL) this allows us to keep track of the volume of requests we get from different private users: no other information is stored.')}}{{if public_key is not None:}}{{=T('If you have not been given an API key, you can use the')}} {{=T('public')}}{{=T('key (')}}
{{=public_key}}{{=T('), which is restricted to')}}{{=public_max_taxa_per_query}}{{=T('taxa per request.')}}
{{pass}}
{{=XML(T('Please remember to cite OneZoom if you use this API in your own project or publication. Use of the OneZoom APIs is subject to our terms of use.') % {'slot0': (xmlescape(URL('default','terms.html/site')))})}}
{{=XML(T('Thanks to Francis Windram there is now an independently maintained R package that gives researchers access to the OneZoom API.'))}}
API/otts2vns'))}}{{=XML(T('An API to get a best hit
vernacular (common) name for an OTT , e.g. %(slot0)s.') % {'slot0': (xmlescape(link(URL('otts2vns', host=True, vars={"key":0, "otts":"770315,244265,542509"}, url_encode=False))))})}}
key{{=public_key}} {{=T('if you have not been given one)')}}{{pass}}ottslangen or fr, or a more specific regional code such as en-gb (British English) or zh-hant (Chinese, in traditional script). If not given, assume enall1 or any truthy value, instead of returning a single best name for each OTT, return an array of names for each OTT, in decreasing order of preference.include_unpreferred1 or any truthy value, and a single name is requested for each OTT (i.e. all is not set), then if there is no name marked as preferredin this language, consider returning a name marked as
unpreferred(i.e. less likely to be correct).
nulls1 or any truthy value, and there is no vernacular in the specified language, return a null value for this OTT in the returned JSON object, otherwise the OTT ID will be absent from the returned objectlanglang string originally used in the request.'))}}all is specified). Unicode characters are represented as e.g. "\\u5c0f"'))}}API/otts2identifiers'))}}{{=XML(T('An API to get identifiers in other databases such as Wikidata and the Encyclopedia of Life, e.g. %(slot0)s.') % {'slot0': (xmlescape(link(URL('otts2identifiers', host=True, vars={"key":0, "otts":"770315,244265,542509"}, url_encode=False))))})}}
{{=XML(T('Currently identifiers are returned for all taxa from the following databases: %(slot0)s, with leaf node taxa having additional identifiers for %(slot1)s. Note that some popular species such as humans have both an official taxonomic
Wikidata entry and a common name
entry (which tends to contain the links to different language wikipedias). In this case we tend to return the common name entry (unless it has no english language wikipedia link).') % {'slot0': (xmlescape(identifier_cols)), 'slot1': (xmlescape(list(set(identifier_leaf_cols)-set(identifier_cols))))})}}
key{{=public_key}} {{=T('if you have not been given one)')}}{{pass}}ottsheadersheaders object provides an integer index into each item returned in the ids object. For example, given a returned object ret the Wikidata Q-ID of humans (OTT 770315) can be accessed using ret.ids["770315"][ret.headers.wikidata]'))}}
idsAPI/node_images'))}}{{=XML(T('An API to get reusable, phylogenetically diverse and representative images for higher taxa. Images are either Creative Commons Attribution only, Creative Commons Share-Alike, or public domain. Each taxon can return URLs to up to 8 square thumbnail images, along with their copyright and licensing information, and a quality score, e.g. %(slot0)s') % {'slot0': (xmlescape(link(URL('node_images', host=True, vars={"key":0, "otts":"244265,361838"}, url_encode=False))))})}}
key{{=public_key}} {{=T('if you have not been given one)')}}{{pass}}ottstypeany, verified or pd, specifying whether to return any representative images, only images that have been verified as correctly identified, or only public domain images. If not given, assume any.taxaname (the scientific name of the input OTT, if it has one) and otts (an array of up to 8 OTTs of species that have "representative" images available).'))}}headersheaders object provides an integer index into each item returned in the images object. For example, given a returned object r the URLs of the first 3 images used to represent mammals (OTT 244265) can be accessed using r.images[r.taxa["244265"].otts[0]][r.headers.url] r.images[r.taxa["244265"].otts[1]][r.headers.url] r.images[r.taxa["244265"].otts[2]][r.headers.url]The headers for each image include
name (scientific name), url, rights (the copyright holder), licence (e.g. CC-BY 2.0 (http://creativecommons.org/licenses/by/2.0/)) and
rating (an image rating, from 0..50000).'))}}imagestypeany, verified or pd) requested.'))}}API/getOTT'))}}{{=T('An API to get the corresponding Open Tree IDs for a variety of identifiers')}}
eolgbifncbiiucneolgbifncbiiucn