[API-users] dataset activity api request paged by date
Gaurav Vaidya
gaurav at ggvaidya.com
Fri Feb 10 22:05:38 CET 2017
> On 10 Feb 2017, at 12:15 PM, Herbario SANT <sant.herbarium at gmail.com> wrote:
>
> Thanks Matthew.
>
> I just want to use the api to maintain a short summary of our datasets
> usage along time. I could run a script regularly to keep a local file
> updated (a table with just a couple of columns: download date and
> number of records downloaded).
>
> But I am facing this problem: the api returns first the LAST download
> event (the most recent one). So the offset value is not a valid
> permanent pointer to any download event.
>
> This difficults paging, specially if you want to space your requests
> every week or so.
> How would I know the offset value for my next request, so I don't
> inject duplicated records to my local file?
>
> This would be much easier to circunvent if the api returns download
> events in reverse order. So, offset=0 would be the first download
> event (happened years ago), and offset=3348 would always point to the
> same download event, whenever it happened.
>
> So, the offset to use for each new request should simply be the
> current total number of records I have already in my local file. No
> risk of duplicated results.
>
> Would it possible to introduce an "order=reverse" option in the api,
> so records could be get returned in the opposite order?
>
> Thanks a lot
>
> David
By way of comparison, MediaWiki’s pagination system doesn’t use offsets at all, but returns a “continue” element, which can then be passed back to the API to indicate “continue from this point” — see https://www.mediawiki.org/wiki/API:Query#Continuing_queries for details. That might work better than an offset, which might change if new records in inserted out of sequence.
cheers,
Gaurav
>
> On 7 February 2017 at 14:19, Matthew Blissett <mblissett at gbif.org> wrote:
>> Hi David,
>>
>> This API method is documented here:
>> http://www.gbif.org/developer/occurrence#download
>>
>> There are no search or filtering parameters accepted, only the paging
>> parameters 'limit' and 'offset'. The data portal URL uses that API call,
>> but itself is just displaying this information, and paging through it.
>>
>> We've experimented with showing a chart for query terms on the demo site, we
>> will consider adding a chart for year of download. Is this related to what
>> you're working on?
>> https://demo.gbif.org/dataset/7f2edc10-f762-11e1-a439-00145eb45e9a/metrics
>>
>> Matt
>>
>> On 05/02/17 16:06, Herbario SANT wrote:
>>>
>>> Hello
>>>
>>> Where can I find a list of all possible api parameters for this api
>>> request?:
>>>
>>> /occurrence/download/dataset/{datasetKey}
>>>
>>> It looks similar to the data portal "dataset download activitiy" url,
>>> which uses an offset parameter for paging download activity using the
>>> links at the end of the page.
>>>
>>> http://www.gbif.org/dataset/{datasetKey}/activity?offset=10
>>>
>>> But ... what other filtering options are there when using the api?
>>>
>>> I wonder if there is a way to request activity related to a certain
>>> date or date range (or to a single year, month). Some examples:
>>>
>>> year=2016
>>> yearRange=2014,2016
>>> date=2017-01-31
>>> dateRange=2016-12-01,2016-12-31
>>>
>>> Of course, I am meaning the "download date", not the "occurrence date".
>>>
>>> Thanks a lot for your help.
>>>
>>
>> _______________________________________________
>> API-users mailing list
>> API-users at lists.gbif.org
>> http://lists.gbif.org/mailman/listinfo/api-users
>
>
>
> --
> David García San León
> Herbario SANT
> Universidade de Santiago de Compostela
> _______________________________________________
> API-users mailing list
> API-users at lists.gbif.org
> http://lists.gbif.org/mailman/listinfo/api-users
More information about the API-users
mailing list