[API-users] Usage of endOfRecords

Nozomi James Ytow nozomi at biol.tsukuba.ac.jp
Mon Dec 22 18:29:45 CET 2014


Hi Tim,

thans for your advice.  My code checkes the returend limit and offset,
and uses them to calculate next offset and limit.  Besides that, what I exepct it that
endOfRecords shoud be true if returned fragment is the end of recoeds.

org.gbif.api.model.common.paging.PagingResponse#isEndOfRecords() contains

if (count != null) {
   return count < offset + limit;
} else if (results != null) {
  return results.size() < limit;
}

I suspect it should be 

if (count != null) {
   return count <= offset + limit;
} else if (results != null) {
  return results.size() <= limit;
}

It doesn't explain, however,  the result of 

http://api.gbif.org/v1/species/search?q=Puma&rank=GENUS&limit=60&offset=0

which satisfies count < offset + limit.  
I guess org.gbif.api.model.common.paging.PagingResponse.endOfRecord is set to be
Boolean.FALSE so it returns false endOfRecord.

Regards,
James

=============================
From: Tim Robertson <trobertson at gbif.org>
Subject: Re: [API-users] Usage of endOfRecords
Date: Mon, 22 Dec 2014 10:49:13 +0100

> The APIs will respect the limit you pass in (e.g. 20 or 50 etc) but sometimes will impose a hard ceiling on the limit (e.g. you may request 10000 but only get 1000 or less back in some APIs).  
> Therefore you should always check the count returned in the response in order to know how to calculate your next offset.


More information about the API-users mailing list