There are several queries you can use to get KPI metrics.

1) query statisticData

Returns single value for one object for specified time interval. For example: Number of visitors from store XY last week. If you are not sure whether to use query statisticData or statisticDataMetric, use statisticDataMetric. This function return raw data stored in database. You have to query the data source directly (camera not the store).

Some available metrics:

More metric types are available in GraphQL scheme / explorer. See StatisticDataMetricType.


2) statisticDataMetric

It is similar to statisticData but it can provide more useful data.

For example: Number of visitors from one store where all store cameras are in location (folder) "San Diego Store" for January 2022.

Available metrics:

More metric types are available in GraphQL scheme / explorer. See StatisticDataMetricType.


3) statisticDataMetricByGranularity

It is similar to statisticDataMetric but it can return more values in a single query. For example: Number of visitors from one folder "San Diego Store" each day separately for January 2022. (granularity for this example is D).

Granularity:

  1. HQ - 15 minutes

  2. H - hour

  3. H4 - 4 hours

  4. H8 - 8 hours

  5. H12 - 12 hours

  6. D - day

  7. W - week

  8. M - month

All metrics in the system are stored with 15 minutes resolution. If query does not align to 15 minutes interval, API will calculate the result using nearby intervals.

Parameters "from" and "to" are in Unix Timestamp format. For testing purposes you can use https://www.unixtimestamp.com/index.php .

Example 1 - Fetching single value:

Query to a folder returns aggregated peopleCountAverage for all cameras in the folder:

query { 
  statisticDataMetric(from:1589186000, to:1589186780, type:peopleCountAverage,node_id:140094)
}​
API Explorer will be opened

Response:

{
  "data": {
    "statisticDataMetric": 57
  }
}

Example 2 - Fetching multiple values (time series):

Query to a folder returns an aggregated peopleCountAverage in 15 minutes granularity:

{
  statisticDataMetricByGranularity(from: 1589186000, to: 1589186780, type: peopleCountAverage, node_id: 63575, granularity: HQ) {
    from
    to
    value
  }
}
API Explorer will be opened

Response:

{
  "data": {
    "statisticDataMetricByGranularity": [
      {
        "from": 1589185800,
        "to": 1589186700,
        "value": 20
      },
      {
        "from": 1589186700,
        "to": 1589187600,
        "value": 12
      }
      ...
    ]
  }
}

(blue star) Related articles

The content by label feature automatically displays related articles based on labels you choose. To edit options for this feature, select the placeholder and tap the pencil icon.