@elpendor opened this Issue on June 7th 2017

I have a site with recorded logs back from 2016.

The following API request only returns results from 2017, when it should include those from 2016 as well:
https://mypiwikinstance/?module=API&method=Live.getLastVisitsDetails&idSite=xx&token_auth=xxxxxxxxxxxxxxx&period=range&date=2016-01-01,2017-12-12

These will return the correct values from the respective year:

https://mypiwikinstance/?module=API&method=Live.getLastVisitsDetails&idSite=xx&token_auth=xxxxxxxxxxxxxxx&period=year&date=2016-01-01

(I get results from 2016)

https://mypiwikinstance/?module=API&method=Live.getLastVisitsDetails&idSite=xx&token_auth=xxxxxxxxxxxxxxx&period=year&date=2017-01-01

(I get results from 2017)

I've reproduced it on 2 different piwik instances. Am I missing something here? "Range" seems to be working fine on other API methods.

The visitor log from the dashboard, on the other hand, seems to be returning the correct results. I don't know exactly if these use the same endpoint to obtain data.

If it's any help, I've already run the archiving process to process all those logs.

Any ideas?

@RMastop commented on June 7th 2017 Contributor

Hi @elpendor,

By default Piwik only returns a partial dataset (100). By using the filter_limit and filter_offset you can get remaining items.

for instance
https://mypiwikinstance/?module=API&method=Live.getLastVisitsDetails&idSite=xx&token_auth=xxxxxxxxxxxxxxx&period=range&date=2016-01-01,2017-12-12&filter_limit=100&filter_offset=0
will get you the 100 most recent records in the selected range,
Where https://mypiwikinstance/?module=API&method=Live.getLastVisitsDetails&idSite=xx&token_auth=xxxxxxxxxxxxxxx&period=range&date=2016-01-01,2017-12-12&filter_limit=100&filter_offset=100 will get you the next batch of 100 records.
By adjusting the integers, you can get larger or smaller datasets.

Cheers,
Richard

@elpendor commented on June 7th 2017

Huh, my bad. I completely missed that part of the documentation.

Thanks, that was it. Working perfect now. I'll close the issue.

This Issue was closed on August 6th 2018
Powered by GitHub Issue Mirror