Neowit developer docs
API referenceSupportKnowledge baseStatusApp
  • Overview
  • REST API
    • Introduction
    • Authentication
      • OAuth2
      • Basic Auth
    • Error codes
    • API reference
    • Coordinate systems
    • Query Language
      • Query Language Reference
  • Service Accounts
    • Introduction
    • Creating service accounts
  • Integrations
    • Introduction
    • MQTT
      • Native Sparkplug
      • Custom Starlark
  • Starlark
    • Introduction
    • Modules
      • time module
      • json module
      • math module
      • devices module
      • series module
      • sensors module
  • Tutorials
    • Introduction
    • Create users using API
Powered by GitBook
On this page
  • Functions
  • agg
  • avg
  • businessdays
  • businesshours
  • clipday
  • combine
  • combine2
  • dayofweek
  • diff
  • fillna
  • get
  • hours
  • linger
  • max
  • min
  • reduce
  • sin
  • sum
  • weekdays
  • zeros
  • Binary Operators
  1. REST API
  2. Query Language

Query Language Reference

Functions

agg

agg(record: record, method: string, fillna: boolean): record Aggregate a record

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to aggregate

method

string

Aggreagation function to apply

"auto", "avg", "lastValue", "max", "min", "sum"

fillna

boolean

Interpolate the input record with last values before aggregating

false

avg

avg(record: record, fillna: boolean): record Average a record

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to average

fillna

boolean

Interpolate the input record with last values before averaging

false

businessdays

businessdays(record: record): record Filter a record to include only business days

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to filter for business days

businesshours

businesshours(record: record): record Filter a record to include only business hours

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to filter for business hours

clipday

clipday(record: record, secondOffsetFromMidnightStart: number, secondOffsetFromMidnightEnd: number): record Filter a record to include only the specified range of seconds offset from midnight

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to clip

secondOffsetFromMidnightStart

number

Number of seconds offset from midnight at the start of each day to start clipping

secondOffsetFromMidnightEnd

number

Number of seconds offset from midnight at the end of each day to end clipping

combine

combine(record: record, method: string, fillna: boolean, neverFillEmptyRows: boolean): record Combine equal sensor types in a record with the specified method

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to combine

method

string

Aggeregation strategy to use when combining sensor types

"auto", "avg", "lastValue", "max", "min", "sum"

fillna

boolean

Interpolate input record with last values before combining

false

neverFillEmptyRows

boolean

false

combine2

combine2(recordX: record, recordY: record, method: string, fillna: boolean, neverFillEmptyRows: boolean): record Combine equal sensor types from two records with the specified method

Parameter
Type
Description
Allowed Values
Default

recordX

record

First input record to combine

recordY

record

Second input record to combine

method

string

Interpolate input record with last values before combining

"auto", "avg", "lastValue", "max", "min", "sum"

fillna

boolean

Interpolate input record with last values before combining

false

neverFillEmptyRows

boolean

false

dayofweek

dayofweek(): series Weekday numbers (monday = 0) for the implicit range

diff

diff(record: record): record The discrete difference for a record

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to differentiate

fillna

fillna(record: record): record Fill NA/NaN values by propagating last valid observation forward to next valid

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to fill with last values

get

get(deviceId: string, sensors: list[string], includes: list[string], excludes: list[string]): record [DEPRECATED] Get a single device record by using device and sensor IDs as strings

Parameter
Type
Description
Allowed Values
Default

deviceId

string

Device ID to retrieve

sensors

list[string]

List of sensor IDs to retrieve, or empty to select all

[]

includes

list[string]

List of tags to use as include filter (devices must match all include tags)

[]

excludes

list[string]

List of tags to use as exclude filter (devices must not match any exclude tags)

[]

get(deviceIds: list[string], sensors: list[string], includes: list[string], excludes: list[string]): record [DEPRECATED[ Get a single record of multiple devices

Parameter
Type
Description
Allowed Values
Default

deviceIds

list[string]

List of Device IDs to retrieve

sensors

list[string]

List of sensor IDs to retrieve, or empty to select all

[]

includes

list[string]

List of tags to use as include filter (devices must match all include tags)

[]

excludes

list[string]

List of tags to use as exclude filter (devices must not match any exclude tags)

[]

hours

hours(record: record, hoursIndexStart: number, hoursIndexEnd: number): record Filter a record to include only the specified hour range

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to filter

hoursIndexStart

number

Index of the starting hour [0-24]

hoursIndexEnd

number

Index of the end hour [0-24]

linger

linger(record: record, duration: number): record Transform a record by delaying each transition to zero for up to duration units of the record resolution

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to linger

duration

number

Number of resolution units to linger for

max

max(record: record, fillna: boolean): record Aggregate by taking the maxium value for each sub interval

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to max over

fillna

boolean

Interpolate input record with last values before maxing

false

min

min(record: record, fillna: boolean): record Aggregate by taking the minimum value for each sub interval

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to min over

fillna

boolean

Interpolate input record with last values before mining

false

reduce

reduce(record: record, fillna: boolean): record Reduce a record by adding up all the resolution intervals, keeping only the last resolution interval

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to reduce

fillna

boolean

Interpolate input record with last values before reducing

false

sin

sin(x: number): number The sine of a number (used mainly for testing)

Parameter
Type
Description
Allowed Values
Default

x

number

sin(series: series): series The sine of a series (used mainly for testing)

Parameter
Type
Description
Allowed Values
Default

series

series

sum

sum(record: record, fillna: boolean): record Aggregate a record using addition

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to sum

fillna

boolean

Interpolate input record with last values before summing

false

weekdays

weekdays(record: record, weekdayIndices: list[number]): record Filter a record to include days from the given list of weekday indices

Parameter
Type
Description
Allowed Values
Default

record

record

The input record to filter

weekdayIndices

list[number]

List of weekday indices to include [0-7]

zeros

zeros(): series A series of all zeros

Binary Operators

Operator
Left Operand Type
Right Operand Type
Result Type
Description

<

number

number

number

Whether the first argument is less than the second argument

<

series

number

series

Yields a series of indicator values for when the series' values are less than the scalar argument

<

number

series

series

Yields a series of indicator values for when the scalar argument is less than the series' values

<

series

series

series

Yields a series of indicator values for when the first series' values are less than the corresponding value in the second series, omitting points absent from either series

<

record

number

record

Yields a record of indicator values for when the record's values are less than the scalar argument

<

number

record

record

Yields a record of indicator values for when the scalar argument is less than the record's values

<

record

series

record

Yields a record of indicator values for when the record's values are less than the corresponding value in the series, omitting points absent from either the record or series

<

series

record

record

Yields a record of indicator values for when the series' values are less than the corresponding value in each of the record's series, omitting points absent from either the record or series

<

record

record

record

Yields a record of indicator values for when the first record' values are less than the corresponding value in the second record, omitting fields and points absent from either record

<=

number

number

number

Whether the first argument is less than or equal to the second argument

<=

series

number

series

Yields a series of indicator values for when the series' values are less than or equal to the scalar argument

<=

number

series

series

Yields a series of indicator values for when the scalar argument is less than or equal to the series' values

<=

series

series

series

Yields a series of indicator values for when the first series' values are less than or equal to the corresponding value in the second series, omitting points absent from either series

<=

record

number

record

Yields a record of indicator values for when the record's values are less than or equal to the scalar argument

<=

number

record

record

Yields a record of indicator values for when the scalar argument is less than or equal to the record's values

<=

record

series

record

Yields a record of indicator values for when the record's values are less than or equal to the corresponding value in the series, omitting points absent from either the record or series

<=

series

record

record

Yields a record of indicator values for when the series' values are less than or equal to the corresponding value in each of the record's series, omitting points absent from either the record or series

<=

record

record

record

Yields a record of indicator values for when the first record' values are less than or equal to the corresponding value in the second record, omitting fields and points absent from either record

>

number

number

number

Whether the first argument is greater than the second argument

>

series

number

series

Yields a series of indicator values for when the series' values are greater than the scalar argument

>

number

series

series

Yields a series of indicator values for when the scalar argument is greater than the series' values

>

series

series

series

Yields a series of indicator values for when the first series' values are greater than the corresponding value in the second series, omitting points absent from either series

>

record

number

record

Yields a record of indicator values for when the record's values are greater than the scalar argument

>

number

record

record

Yields a record of indicator values for when the scalar argument is greater than the record's values

>

record

series

record

Yields a record of indicator values for when the record's values are greater than the corresponding value in the series, omitting points absent from either the record or series

>

series

record

record

Yields a record of indicator values for when the series' values are greater than the corresponding value in each of the record's series, omitting points absent from either the record or series

>

record

record

record

Yields a record of indicator values for when the first record' values are greater than the corresponding value in the second record, omitting fields and points absent from either record

>=

number

number

number

Whether the first argument is greater than or equal to the second argument

>=

series

number

series

Yields a series of indicator values for when the series' values are greater than or equal to the scalar argument

>=

number

series

series

Yields a series of indicator values for when the scalar argument is greater than or equal to the series' values

>=

series

series

series

Yields a series of indicator values for when the first series' values are greater than or equal to the corresponding value in the second series, omitting points absent from either series

>=

record

number

record

Yields a record of indicator values for when the record's values are greater than or equal to the scalar argument

>=

number

record

record

Yields a record of indicator values for when the scalar argument is greater than or equal to the record's values

>=

record

series

record

Yields a record of indicator values for when the record's values are greater than or equal to the corresponding value in the series, omitting points absent from either the record or series

>=

series

record

record

Yields a record of indicator values for when the series' values are greater than or equal to the corresponding value in each of the record's series, omitting points absent from either the record or series

>=

record

record

record

Yields a record of indicator values for when the first record' values are greater than or equal to the corresponding value in the second record, omitting fields and points absent from either record

==

number

number

number

Whether the first argument is equal to the second argument

==

series

number

series

Yields a series of indicator values for when the series' values are equal to the scalar argument

==

number

series

series

Yields a series of indicator values for when the scalar argument is equal to the series' values

==

series

series

series

Yields a series of indicator values for when the first series' values are equal to the corresponding value in the second series, omitting points absent from either series

==

record

number

record

Yields a record of indicator values for when the record's values are equal to the scalar argument

==

number

record

record

Yields a record of indicator values for when the scalar argument is equal to the record's values

==

record

series

record

Yields a record of indicator values for when the record's values are equal to the corresponding value in the series, omitting points absent from either the record or series

==

series

record

record

Yields a record of indicator values for when the series' values are equal to the corresponding value in each of the record's series, omitting points absent from either the record or series

==

record

record

record

Yields a record of indicator values for when the first record' values are equal to the corresponding value in the second record, omitting fields and points absent from either record

!=

number

number

number

Whether the first argument is not equal to the second argument

!=

series

number

series

Yields a series of indicator values for when the series' values are not equal to the scalar argument

!=

number

series

series

Yields a series of indicator values for when the scalar argument is not equal to the series' values

!=

series

series

series

Yields a series of indicator values for when the first series' values are not equal to the corresponding value in the second series, omitting points absent from either series

!=

record

number

record

Yields a record of indicator values for when the record's values are not equal to the scalar argument

!=

number

record

record

Yields a record of indicator values for when the scalar argument is not equal to the record's values

!=

record

series

record

Yields a record of indicator values for when the record's values are not equal to the corresponding value in the series, omitting points absent from either the record or series

!=

series

record

record

Yields a record of indicator values for when the series' values are not equal to the corresponding value in each of the record's series, omitting points absent from either the record or series

!=

record

record

record

Yields a record of indicator values for when the first record' values are not equal to the corresponding value in the second record, omitting fields and points absent from either record

+

number

number

number

Adds the first argument with the second argument

+

series

number

series

Adds the scalar argument to the series' values and yields a series with the result

+

number

series

series

Adds the series' values to the scalar argument and yields a series with the result

+

series

series

series

Adds the first series' values to the correspondong value in the second series and yields a series with the result, omitting points absent from either series

+

record

number

record

Adds the scalar argument to the record's values and yields a record with the result

+

number

record

record

Adds the record's values to the scalar argument and yields a record with the result

+

record

series

record

Adds each record series' values to the correspondong value in the series and yields a record with the result, omitting points absent from either the record or series

+

series

record

record

Adds the series' values to the correspondong value in each of the record's series and yields a record with the result, omitting points absent from either the record or series

+

record

record

record

Adds the first record's values to the correspondong value in the second record and yields a record with the result, omitting fields and points absent from either record

-

number

number

number

Subtracts the second argument from the first argument

-

series

number

series

Subtracts the scalar argument from the series' values and yields a series with the result

-

number

series

series

Subtracts the series' values from the scalar argument and yields a series with the result

-

series

series

series

Subtracts the second series' values from the correspondong value in the first series and yields a series with the result, omitting points absent from either series

-

record

number

record

Subtracts the scalar argument from the record's values and yields a record with the result

-

number

record

record

Subtracts the record's values from the scalar argument and yields a record with the result

-

record

series

record

Subtracts the series' values from the correspondong value in each of the record's series and yields a record with the result, omitting points absent from either the record or series

-

series

record

record

Subtracts each record series' values from the correspondong value in the series and yields a record with the result, omitting points absent from either the record or series

-

record

record

record

Subtracts the second record's values from the correspondong value in the first record and yields a record with the result, omitting fields and points absent from either record

*

number

number

number

Multiplies the first argument with the second argument

*

series

number

series

Multiplies the series' values with the scalar argument and yields a series with the result

*

number

series

series

Multiplies the scalar argument with the series' values and yields a series with the result

*

series

series

series

Multiplies the first series' values with the correspondong value in the second series and yields a series with the result, omitting points absent from either series

*

record

number

record

Multiplies the record's values with the scalar argument and yields a record with the result

*

number

record

record

Multiplies the scalar argument with the record's values and yields a record with the result

*

record

series

record

Multiplies each record series' values with the correspondong value in the series and yields a record with the result, omitting points absent from either the record or series

*

series

record

record

Multiplies the series' values with the correspondong value in each of the record's series and yields a record with the result, omitting points absent from either the record or series

*

record

record

record

Multiplies the first record's values with the correspondong value in the second record and yields a record with the result, omitting fields and points absent from either record

/

number

number

number

Divides the first argument by the second argument

/

series

number

series

Divides the series' values by the scalar argument and yields a series with the result

/

number

series

series

Divides the scalar argument by the series' values and yields a series with the result

/

series

series

series

Divides the first series' values by the correspondong value in the second series and yields a series with the result, omitting points absent from either series

/

record

number

record

Divides the record's values by the scalar argument and yields a record with the result

/

number

record

record

Divides the scalar argument by the record's values and yields a record with the result

/

record

series

record

Divides each record series' values by the correspondong value in the series and yields a record with the result, omitting points absent from either the record or series

/

series

record

record

Divides the series' values by the correspondong value in each of the record's series and yields a record with the result, omitting points absent from either the record or series

/

record

record

record

Divides the first record's values by the correspondong value in the second record and yields a record with the result, omitting fields and points absent from either record

%

number

number

number

Computes the modulo of the first argument with the second argument

%

series

number

series

Computes the modulo of the series' values with the scalar argument and yields a series with the result

%

number

series

series

Computes the modulo of the scalar argument with the series' values and yields a series with the result

%

series

series

series

Computes the modulo of the first series' values with the correspondong value in the second series and yields a series with the result, omitting points absent from either series

%

record

number

record

Computes the modulo of the record's values with the scalar argument and yields a record with the result

%

number

record

record

Computes the modulo of the scalar argument with the record's values and yields a record with the result

%

record

series

record

Computes the modulo of each record series' values with the correspondong value in the series and yields a record with the result, omitting points absent from either the record or series

%

series

record

record

Computes the modulo of the series' values with the correspondong value in each of the record's series and yields a record with the result, omitting points absent from either the record or series

%

record

record

record

Computes the modulo of the first record's values with the correspondong value in the second record and yields a record with the result, omitting fields and points absent from either record

PreviousQuery LanguageNextIntroduction

Last updated 15 days ago