Reporting API date range problem

HI, I have a strange problem with the reporting API calls using range dates:
If I look for quarterly data using the following call
https:///index.php?module=API&method=Events.getAction&idSite=7&date=2022-04-01,2022-06-30&period=range&token_auth= the call returns nothing, but if I use
https:///index.php?module=API&method=Events.getAction&idSite=7&date=2022-04-01,2022-06-29&period=range&token_auth= or
https:///index.php?module=API&method=Events.getAction&idSite=7&date=2022-04-01,2022-06-31&period=range&token_auth= it returns the correct numbers.

This happens to any quarter and any year.

How am I supposed to look for quarterly data?

Can you check this (bad) behavior on the demo site:
https://demo.matomo.cloud
(no need of a token_auth)
If this (bad) behaviour is still there, you can create an issue at:

Hi Philippe,
Thank you very much for your prompt response.

In order for me to make an API call I need to provide site Id Usually the site id is found by going to


but I do not see the Websites menu item on the demo website

How can I find site id on the Matomo demo site?

Thank you.
Alla

Here is what I see on the Matomo demo site

In the demo site, idsite=1

Hi Philippe,

Again, thank you for your prompt response. Of course, it works fine on the demo website. The only thing that I found odd on my Matomo installation and the demo website. Is that it allows using non-exiting dates in the date range parameter. Here I used 06/31/2022 and got results

The strange behavior I observe on my Matomo installation is that one day the same API calls return that expected data, and the next day they do not.

For example, on 04/26/2022 the calls
https://analytics.bsc.gwu.edu/index.php?module=API&method=Events.getAction&idSite=7&date=2022-04-01,2022-06-30&period=range&token_auth=

and the previous call with date=2022-04-01,2022-06-29
returned nothing
the call
https://analytics.bsc.gwu.edu/index.php?module=API&method=Events.getAction&idSite=7&date=2022-04-01,2022-06-28&period=range&token_auth=
returned the data for the second quarter
but today all calls listed above return the data for the second quarter as expected.

Any suggestions how to troubleshoot this are greatly appreciated.

Thank you.
Alla

How do you archive data?
Archiving process is used to compile data used by reports:

Hi Philippe,

Here is how my archiving options are set:

How do the data need to be archived in order for me to get correct results every day using API calls?

Thank you.
Alla

Do you know if you have a CRON (or task scheduler) that archive Matomo data?
Also coming back to your initial issue, do you see some error in the Matomo log (eg. timeout, etc.)?

Yes, I do have a CRON job that runs every hour.
And no, I do not have any errors in the Matomo log when the request returns an empty set.

@innocraft any idea?

It’s likely here that your server is either running out of Memory or you’re just hitting a time out for the request. The reason it doesn’t work one day and works the next is because the server keeps trying to process the data even after the request times out.

You will likely need to increase the max_execution_time in your PHP.ini
You also probably won’t see an error in your Matomo logs but you might see the error in your PHP error logs.

Locate your php.ini file. Once you’ve located the php.ini file, look for the following line:

; Maximum execution time of each script, in seconds
; https://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30

Increase it as you see fit. For large Matomo instances, we recommend setting it to 0; this sets it to limitless.

Remember to restart your web server.

There are no errors in my PHP error log and requests do not timeout.
There is another post that reported a problem similar to mine Date range gives wrong data - #14 by heurteph-ei I tried all suggestion for there and it does not help.
I am currently using Matomo 4.12.0

Here are some screenshots from Matomo dashboard


As you can see, according to Matomo there are Events from 04/01/2022 to 06/30/2022

But


there are events from 04/01/2022 to 07/02/2022

However here is the number of events from 07/01/2022 to 07/02/2022

As you can see, they do not add up to the total number of events from 04/01/2022 to 07/02/2022

How can this problem be fixed? What do I need to do?

Please help.

Thank you.
Alla

Hi @Alla_A_Sapozhnikova
On your first screenshot, there is a message saying that there was some problem with data archiving…
This probably causes the display error… Is there any error in the archiving log file?
Also, what is the result for April, May and June?