this might be another way to work around the issue (written in Python) without doing any extra requests: https://forum.inaturalist.org/t/inaturalist-api-with-python-get-family-name-from-observations/53672/4
… and here’s a Javascript function adapted from the above which will return ancestors for a given observation (implemented in https://jumear.github.io/stirfry/iNatAPIv1_observations):
function fObsTaxonAncestors(obs) {
let ancestors = [];
let rankLevel_kingdom = 70 // this is the highest-level taxon stored in identification[i].ancestors
let rt, taxonId, rankLevel;
if ((rt = obs?.taxon) && (taxonId = rt?.id) && ((rankLevel = rt?.rank_level) < rankLevel_kingdom)) {
for (let id of obs.identifications) {
let idt, idta;
if (idt = id?.taxon) {
if (idt.id === taxonId) {
ancestors = idt.ancestors;
break;
};
if (idta = idt.ancestors) {
for (let [i, atid] of idta.map((a)=>a.id).entries()) {
if (atid === taxonId) {
ancestors = idta.slice(0,i); // add everything above this taxon (will add this taxon later below)
break;
};
};
};
if (ancestors?.length) { break; };
};
};
};
if (rt && rankLevel <= rankLevel_kingdom) {
ancestors.push(rt); // add self taxon
return ancestors;
};
};