goatcounter
goatcounter copied to clipboard
API for per-day stats
I'm looking to bring my analytics data into Grafana since I already have everything else there. While trying to do so, I noticed there's no real way to transform the current data on GET /stats/hits
into a total sum of hits per day, given the limited number of ways I have to process the data (JSONPath
and JSONata
, neither of which support the transformation required to get a sum per day). I can't make multiple API requests either, it all has to be done in one request.
About the only workaround I can see is a new API endpoint that returns data something like this, combined across all routes as a total sum.
{
"total": 1000,
"per_day": [
{
"date": "2023-09-05",
"pageviews": 18,
"visitors": 8
},
{
"date": "2023-09-06",
"pageviews": 10,
"visitors": 3
},
{
"date": "2023-09-07",
"pageviews": 8,
"visitors": 1
}
]
}
Adding this to the existing GET /stats/total
would also be doable for my use case.