Skip to main content
Version: 1.1

clarify.evaluate

Require access to Clarify namespace

For an integration to access this method, it must have been granted access to the Clarify namespace.

A data method for aggregating time-series data and perform evaluate formula expressions.

Method parameters

ParameterPropertiesDescription
items
array(Item aggregation)
default=[]List of item aggregations.
calculations
array(Calculation)
default=[]List of calculations.
data
Data query
default={}Data query to filter/aggregate the returned data framerollup-required.
include
array(string("item"))
default=[]Relationships to include.
format
Selection format
default={"dataAsArray":false,"groupIncludedByType":false}Configure result format.

Item aggregation

Item aggregation describe a particular aggregation method for an item.

FieldDescription
id
Item ID
Item to aggregate.
aggregation
Data aggregation
Aggregation method.
state
integer([0:9999])
State value for state-histogram aggregation methods.
lead
integer([-1000:1000])
Shift buckets backwards by N.bucket-offset
lag
integer([-1000:1000])
Shift buckets forwards by N.bucket-offset
alias
Alias
A short alias to use in formulas as well as in the data frame results.

Calculation

A calculation has access to items and previous calculations in context.

FieldDescription
formula
Calculation formula
A calculation formula.
alias
Alias
A short alias to use in formulas as well as in the data frame results.

Result

The result contains a data frame with aggregated and evaluated time-series data, as well as side-loaded item meta-data if requested.

type: object

FieldDescription
meta
Selection meta
Selection meta data.
data
Data frame,array(Data frame)
A matrix view of selected/aggregated data points.
included
array(resource),map(string => array(resource))
Side-loaded resources from relationships.

Limits

Items:

  • items:

    • You are limited to reference 50 unique item IDs.

Calculations:

  • calculations:

    • You are limited to list 100 calculations.
    • Each formula is limited to 1000 characters.

Data query:

  • data.filter.times:

    • Maximum window size is:
      • 40 days (40 * 24 hours) when rollup is less than PT1M (1 minute).
      • 400 days (400 * 24 hours) whenrollup is greater than or equal to PT1M (1 minute).
      • 1900 days (1900 * 24 hours) whenrollup is greater than or equal to PT24H (24 hours).
      • Without limit when rollup is window.
  • data.filter.times.$gte:

    • Defaults to $lt - 14 days when $lt is set.
    • Defaults to now - 7 days otherwise.
  • data.filter.times.$lt:

    • Defaults to $gte + 14 days.

Example

The curl example uses Basic Auth for simplicity.

curl -u ${BASIC_AUTH_USERNAME}:${BASIC_AUTH_PASSWORD} \
--request POST \
--url 'https://api.clarify.io/v1/rpc' \
--header 'content-type: application/json' \
--header 'X-API-Version: 1.1' \
--data \
'
{
"jsonrpc": "2.0",
"id": 1,
"method": "clarify.evaluate",
"params": {
"items": [
{
"id": "ci3eqq0bi2apjoiemb20",
"alias": "i1",
"aggregation": "avg",
"lead": 1
},
{
"id": "ci3eqq0bi2apjoiemb2g",
"alias": "i2",
"aggregation": "sum",
"lag": 1
},
{
"id": "ci3eqq0bi2apjoiemb30",
"alias": "i3",
"aggregation": "sum"
}
],
"calculations": [
{
"formula": "gapfill(i2) + i3",
"alias": "c1"
},
{
"formula": "i1 / c1",
"alias": "c2"
}
],
"data": {
"rollup": "P1D",
"timeZone": "UTC",
"firstDayOfWeek": 1,
"filter": {
"times": {
"$gte": "2023-06-15T00:00:00Z",
"$lt": "2023-06-20T00:00:00Z"
},
"series": {
"$in": [
"i1",
"i2",
"i3",
"c1",
"c2"
]
}
}
}
}
}
'

Results:

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"meta": {
"total": 5,
"format": {
"groupIncludedByType": false,
"dataAsArray": false
}
},
"data": {
"times": [
"2023-06-15T00:00:00Z",
"2023-06-16T00:00:00Z",
"2023-06-17T00:00:00Z",
"2023-06-18T00:00:00Z",
"2023-06-19T00:00:00Z"
],
"series": {
"c1": [192, 192, 192, 192, 192],
"c2": [
0.36262936708726135, 0.2654939498258671, -0.4030798814736652,
-0.26349481692193893, 0.407358729183466
],
"i1": [
69.62483848075418, 50.97483836656648, -77.39133724294372,
-50.59100484901228, 78.21287600322547
],
"i2": [72, 72, 72, 72, 72],
"i3": [120, 120, 120, 120, 120]
}
}
}
}

  1. The data.rollup property must be set to window or an RFC3339 duration string for this request.
  2. The final bucket offset to use is calculated as lead - lag, and must be in range [-1000:1000].