This article covers the query support available within the Digi RM3 /ws/v1/streams API.
Query support is something which exists in many of the v1 APIs within Digi RM3, but until now it was missing from /ws/v1/streams/inventory
, due to the streams API having a different backend storage model than the other Digi RM3 APIs. Further development by the Digi RM Development team have now made this possible.
The query language used for the streams API shares the same query syntax as the other v1 APIs, so the Programmer's Guide can be referenced for the fundamentals of what the query language supports. The fields supported in the streams query language include id, customer_id, units, description, type, and last_update.
A useful but basic example would be to look for all of the streams for a particular device. To accomplish this you could use the startsWith operator: /ws/v1/streams/inventory?query=id startsWith '00000000-00000000-00042DFF-FF000000', which will return any streams with an id matching that prefix. If your Digi RM device inventory contains devices that upload DIA or Smart Energy data, it's possible the device id will occur in the middle of the id, in which case you may want to use the contains operator instead: /ws/v1/streams/inventory?query=id contains '00000000-00000000-00042DFF-FF000000'
Alternatively you may want to look for streams of a particular type. Perhaps you are only interested in numeric streams in order to do some calculations on the values...so you could retrieve this using the type field: /ws/v1/streams/inventory?query=type='integer' or type='long' or type='float' or type='double'
The last_update time column can be used to check for streams that have changed recently. Times can be queried using literal or relative times. An example of a relative time to check for streams updated within the last hour would look like: /ws/v1/streams/inventory?query=last_update>-1h
- Fields related to the value aren't currently allowed in the query (such as value, timestamp and server_timestamp)
Oct 27, 2021