
Hi, I tried http://api.gbif.org/v1/species/search?q=Puma&rank=GENUS&limit=20&offset=0 which returns JSON starting with {"offset":0,"limit":20,"endOfRecords":false,"count":50,"results":[ I expect that there are 50 records to be returend against the query. Howerver, http://api.gbif.org/v1/species/search?q=Puma&rank=GENUS&limit=60&offset=0 returns 50 records as expected, but it says as {"offset":0,"limit":50,"endOfRecords":false,"count":50,"results":[ Shouldn't it be true, if the returned fragment represents end of records? Or, shoud I check not only endOfRecords but also (limit > 0 && (offset + limit) < count) ? -- James

Hi James, 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. Thanks, Tim On 20 Dec 2014, at 09:59, Nozomi James Ytow <nozomi@biol.tsukuba.ac.jp> wrote:
Hi,
I tried
http://api.gbif.org/v1/species/search?q=Puma&rank=GENUS&limit=20&offset=0
which returns JSON starting with
{"offset":0,"limit":20,"endOfRecords":false,"count":50,"results":[
I expect that there are 50 records to be returend against the query. Howerver,
http://api.gbif.org/v1/species/search?q=Puma&rank=GENUS&limit=60&offset=0
returns 50 records as expected, but it says as
{"offset":0,"limit":50,"endOfRecords":false,"count":50,"results":[
Shouldn't it be true, if the returned fragment represents end of records? Or, shoud I check not only endOfRecords but also (limit > 0 && (offset + limit) < count) ? -- James
_______________________________________________ API-users mailing list API-users@lists.gbif.org http://lists.gbif.org/mailman/listinfo/api-users

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@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.

From: Nozomi "James" Ytow <nozomi@biol.tsukuba.ac.jp> Date: Tue, 23 Dec 2014 02:29:45 +0900 (JST)
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.
Oops. It may explain, becuase returned values does not satisfy count < offset + limit. but count == offset + limit. Regards, James

Thanks James for reporting the bug. http://api.gbif.org/v1/species/search?q=Puma&rank=GENUS&limit=100 Indeed that should show endOfRecord=true I’ll file an issue for that. Thanks, Tim On 22 Dec 2014, at 18:35, Nozomi James Ytow <nozomi@biol.tsukuba.ac.jp> wrote:
From: Nozomi "James" Ytow <nozomi@biol.tsukuba.ac.jp> Date: Tue, 23 Dec 2014 02:29:45 +0900 (JST)
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.
Oops. It may explain, becuase returned values does not satisfy count < offset + limit. but count == offset + limit.
Regards, James _______________________________________________ API-users mailing list API-users@lists.gbif.org http://lists.gbif.org/mailman/listinfo/api-users
participants (2)
-
Nozomi James Ytow
-
Tim Robertson