Stats Timeseries

The timeseries query lets you group the aggregation results into time buckets.

For example, some of the things you can compute with this query are:

  • Count unique visitors and pageviews per day.
  • Analyze page load time trends over time.
  • Compute the change in bounce rate vs pages per visit over the past year.

Endpoint

POST /v1/stats/timeseries

This endpoint responds with 200 - Success if successful, and will include a JSON object a list of entries grouped by the timestamp field (ts) in ISO 8601 format.

JSON Parameters

FieldTypeDescription
site_idstringThe Site ID to query. required
aggregatestring listA list of dimensions to aggregate on. required
periodstringThe time window to aggregate. See time periods for valid values. Default: 1h. optional
filterobject listList of query filters to apply. optional
timezonestringTimezone to use for all time window calculations. For example: America/Costa_Rica. Refer to the list of timezones for possible timezone names. Default: UTC. optional

Time buckets

By default, Panelbear picks a reasonable time bucket default for you. This parameter controls the unit of time by which your query results are grouped.

You can use a different time_bucket value than the default, but you must make sure to use a value that is allowed for the time period you're querying:

Time bucketDescription
minuteGroup timeseries results by minute. Available in periods: 1h.
hourGroup timeseries results by hour. Available in periods: 24h, today, 7d.
dayGroup timeseries results by day. Available in periods: 7d, 4w, 3m, 12m, mtd, ytd.
weekGroup timeseries results by week. Available in periods:4w, 3m, 12m, mtd, ytd.
monthGroup timeseries results by month. Available in periods: 3m, 12m, mtd, ytd.

Examples

Unique visitors over the past month

The following JSON query returns the unique visitor count over the past four weeks for your given <SITE_ID> using the default time bucket for this time period (day), and default timezone (UTC).

$ curl -X POST \
       -H "Authorization: Bearer <TOKEN>" \
       -H "Content-type: application/json" \
       "https://api.panelbear.com/v1/stats/timeseries" \
       -d '{
            "site_id": "<SITE_ID>",
            "period": "4w",
            "aggregate": ["session_count"]
        }'

< HTTP/1.1 200 OK
< Content-Type: application/json
{
	"time_bucket": "day",
	"data": [
        {
			"ts": "2021-01-01T00:00:00Z",
			"session_count": 1571
		},
        {
			"ts": "2021-01-02T00:00:00Z",
			"session_count": 1502
		},
        {
			"ts": "2021-01-03T00:00:00Z",
			"session_count": 1495
		}
        ...
	]
}

Page load time over the past 24 hours, specific timezone

The following JSON query returns the average load time over the past 24 hours for your given <SITE_ID>, using a specific time zone.

$ curl -X POST \
       -H "Authorization: Bearer <TOKEN>" \
       -H "Content-type: application/json" \
       "https://api.panelbear.com/v1/stats/timeseries" \
       -d '{
            "site_id": "<SITE_ID>",
            "period": "24h",
            "aggregate": ["page_load_avg"],
            "timezone": "Europe/London"
        }'

< HTTP/1.1 200 OK
< Content-Type: application/json
{
	"time_bucket": "hour",
	"data": [
        {
			"ts": "2021-01-01T15:00:00+01:00",
			"page_load_avg": 550
		},
        {
			"ts": "2021-01-01T16:00:00+01:00",
			"page_load_avg": 580
		},
        {
			"ts": "2021-01-01T17:00:00+01:00",
			"page_load_avg": 563
		}
        ...
	]
}