How to find the top improving identifiers for a taxon?

Is there a way to find, say, the top 50 improving identifiers for a particular taxon? Not leading, supporting, or maverick.

4 Likes

It seems to be possible using the inat api. The GET/identifications/identifiers method “returns creators of identifications matching the search criteria and the count of matching identifications, ordered by count descending”. So for example a url to get the top 50 improving identifiers for Pieris brassicae would be:

https://api.inaturalist.org/v1/identifications/identifiers?current_taxon=true&own_observation=false&is_change=false&current=true&category=improving&taxon_id=55401&per_page=50&order=desc&order_by=created_at

The results are returned as json - which displays quite nicely in Firefox, but I’m not sure about other browsers. I don’t think there’s any way to adapt this method to get formatted output similar to the identifications page, though.

here’s something that might help to display that json in a format that’s a little more friendly. just copy the code below into a text / html / code editor and save it as an .html file. then open up the file in any browser. feel free to modify as you like.

<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="iNaturalist API Get Identifiers" />
<title>iNaturalist API Get Identifiers</title>
<style>
   body { font:10pt Sans-Serif; }
   .tar { text-align:right; }
   #main { width:100%; }
   table, thead, tbody, tr, td { margin:0px; padding:3px; border-width:1px 0px;border-style:solid; border-color:lightgray; border-spacing:0px; border-collapse:collapse; }
   thead tr { font-weight:600; background:green; color:white; }
   tr { background:whitesmoke; }
   tr:nth-child(even) {background-color:white }
   .icon { height:48px; width:48px; border-radius:50%; }
   img { margin:0px; padding:0px; border:0px; }
   a { text-decoration:none; }
</style>
</head>

<body>
<script>
function furl(url,txt=url) { return '<a href="'+url+'">'+txt+'</a>'; };
function famp(str) { return str.replace(/&/g,'&amp;'); };
function fdate(str) {
//   str = str.replace(/t/i,' '); //replaces T (case insensitive) with a space
//   str = str.replace(/z/i,' GMT'); //replaces Z (case insensitve) with GMT
//   str = str.replace(/([+-]\d{2}\:?\d{2})/,' GMT$1'); //adds GMT prefix to timezone offset
//   return str;
   return str.substring(0,10);
};
function faddelem(etype,eparent,eclass=null,eid=null,ehtml=null) {
   var eobj = document.createElement(etype);
   if (eclass!==null) { eobj.classList = eclass };
   if (eid!==null) { eobj.id = eid };
   if (ehtml!==null) { eobj.innerHTML = ehtml };
   eparent.appendChild(eobj);
   return eobj;
};
function fresults(xobj) {
   faddelem('p',document.body,null,null,famp(apiurl));
   var results = xobj.results;
   if (results) {
      faddelem('p',document.body,null,null,'total identifiers: '+xobj.total_results);
      var table = faddelem('table',document.body,null,'main');
      var thead = faddelem('thead',table);
      var hrow = faddelem('tr',thead);
      faddelem('td',hrow,null,null,'rank');
      faddelem('td',hrow,null,null,'icon');
      faddelem('td',hrow,null,null,'user id');
      faddelem('td',hrow,null,null,'login id');
      faddelem('td',hrow,null,null,'user name');
      faddelem('td',hrow,null,null,'joined date');
      faddelem('td',hrow,'tar',null,'ids');
      faddelem('td',hrow,'tar',null,'total ids');
      var tbody = faddelem('tbody',table);
      for (var i=0; i<results.length; i++) {
         var brow = faddelem('tr',tbody);
         faddelem('td',brow,null,null,i+1);
         faddelem('td',brow,null,null,'<img class="icon" src="'+results[i].user.icon+'" />');
         faddelem('td',brow,null,null,furl('https://www.inaturalist.org/users/'+results[i].user_id,results[i].user_id));
         faddelem('td',brow,null,null,results[i].user.login);
         faddelem('td',brow,null,null,results[i].user.name);
         faddelem('td',brow,null,null,fdate(results[i].user.created_at));
         faddelem('td',brow,'tar',null,results[i].count);
         faddelem('td',brow,'tar',null,results[i].user.identifications_count);
      };
   }
   else { faddelem('p',document.body,null,null,'No results returned.'); };
};
var apiurl = 'https://api.inaturalist.org/v1/identifications/identifiers'+window.location.search;
if (window.location.search==='') {
   faddelem('p',document.body,null,null,'This page displays the results of a request to the iNaturalist Identifiers API in a user-friendly format. To use this page, add at least one query parameter to the URL. See '+furl('https://api.inaturalist.org/v1/docs/#!/Identifications/get_identifications_identifiers')+' for available query parameters.');
   faddelem('p',document.body,null,null,'Suppose this page is saved locally as C:\\example.html, <br />and you want to see the results of '+furl(famp('https://api.inaturalist.org/v1/identifications/identifiers?&own_observation=false&is_change=false&current=true&category=improving&taxon_id=55401&per_page=50'))+' in a friendly format, <br />then you would open '+furl(famp('file:///C:/example.html?&own_observation=false&is_change=false&current=true&category=improving&taxon_id=55401&per_page=50'))+' in your browser.');
}
else {
   fetch(apiurl)
      .then((response) => {
         if (!response.ok) { throw Error(response.statusText); };
         return response.json();
      })
      .then((data) => { fresults(data); })
      .catch((err) => { console.log('Error: '+err); });
}
</script>
</body>
</html>