Time Format in the REST API and WebHooks

All datasets delivered in response to REST API requests and WebHooks provide a timestamp in UTC. Therefore there will need to be a conversion applied at the endpoint. In the case of the REST API JSON request, the data is provided in an epoch format and will need to be parsed. See the examples below.

WebHook time

In example below, the JSON in the WebHook includes a “date” value for the Gateway message, and a “messageDate” value in the Sensor message.

The Gateway’s “date” value - This represents the date in UTC on which the gateway delivered this communication to the iMonnit server. In the below JSON, the “date” value in the “gatewayMessage” JSON is 2020-09-04 14:50:38 UTC. If this were translated to Mountain time for example, it would be 9/3/2020 8:50:38 AM.

The Sensor’s “messageDate” value - This represents the date in UTC on which the sensor created the reading and transmitted it to the gateway. In the below JSON, the “messageDate” value in the “sensorMessage” JSON is “2020-09-04 14:47:37” UTC. If this were translated to Mountain time for example, it would be 9/3/2020 8:47:37 AM.

{

"gatewayMessage":{

"gatewayID":"xxxxxx" ,

"gatewayName":"Ethernet Gateway 1 - xxxxxx" ,

"accountID":"xxxxxx",

"networkID":"xxxxxx" ,

"messageType":"0" ,

"power":"0",

"batteryLevel": "101" ,

"date": "2020-09-04 14:50:38",

"count":"1",

"signalStrength": "0",

"pendingChange": "False"

},

"sensorMessages":[

{

"sensorID":"xxxxxx" ,

"sensorName":"Garage - xxxxxx",

"applicationID":"9",

"networkID":"xxxxxx",

"dataMessageGUID":"c469dcba-c230-4206-8ba2-25d7xxxxxx",

"state": "0",

"messageDate": "2020-09-04 14:47:37",

"rawData":"False",

"dataType": "DoorData|MagnetDetect",

"dataValue": "False|False",

"plotValues": "0|0",

"plotLabels": "Door Position|Magnet Position",

"batteryLevel": "40",

"signalStrength": "100",

"pendingChange": "True",

"voltage": "2.32"

}

]

}


REST API time

The REST API also delivers time relative to UTC. The time value differs between the XML requests and JSON requests. The JSON REST API time value differs from the WebHook and XML REST request in that the REST API time value is in the form of a .NET Epoch time format. You can see this in the data below.

REST API JSON time

In the below JSON response to the REST API request, you will see the “MessageDate”: “Date(1599232716000)” value to represent the date. This value is the date which the sensor took the reading and transmitted it to the gateway.

The format of the date is in an epoch .NET format. If you parse the numerical value, you can see that if you translate this value using this Epoch Converter tool, it is converted to 9/4/2020 3:18:36 PM UTC or 9/3/2020 9:18:36 AM Mountain.

{"Method":"AccountRecentDataMessages",

"Result":[{

"DataMessageGUID":"577b2faa-ce10-4d16-8fb3042c9fxxxxxx",

"SensorID":xxxxxx,

"MessageDate":"/Date(1599231620000)/",

"State":0,

"SignalStrength":100,

"Voltage":1.87,

"Battery":0,

"Data":"38.14,21.47,6.6,43.1",

"DisplayData":"38.14% @ 70.6° F D: 43.9° F GPP:43.1",

"PlotValue":"38.14",

"MetNotificationRequirements":false,

"GatewayID":xxxxxx,

"DataValues":"38.14|21.47|6.6|43.1",

"DataTypes":"Percentage|TemperatureData|TemperatureData|MoistureWeight",

"PlotValues":"38.14|70.646|43.88|43.1",

"PlotLabels":"Humidity|Fahrenheit|DewPoint|GrainsPerPound"

}

]

}


REST API XML time

The REST API XML time is provided in a human readable format in UTC. In the below XML response from the REST API request, you will see the MessageDate=“9/4/2020 4:00:20 PM” value. This represents the date in UTC on which the sensor created the reading and transmitted it to the gateway. If this were translated to Mountain time for example, it would be 9/3/2020 10:00:20 AM.

AccountRecentDataMessages


Conclusion

You can contact support@monnit.com if you have related inquiries.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.