This is a question we got to our support. Since other might be wondering I answer it here as well.
The question was how do I get the latest value from a sensor (=device) using the API?
There are two options for this. Either the log endpoint with limit=1 or, probably better, the status endpoint.
Let's go with the status endpoint. The status API is used for instance if you want the current state of a whole installation. For example to present in a GUI. So without other arguments but the installation ID you get the whole installation.
curl -s -X GET -H "X-API-Key:$TOKEN" https://lynx.iotopen.se/api/v2/status/16
Please note that for large installations this might take a while, but since you get a lot of data it might be worth it.
The key to data is the topic. We can limit what we get by adding topics to the url. Like this:
curl -s -X GET -H "X-API-Key:$TOKEN" https://lynx.iotopen.se/api/v2/status/16?tokens=obj/zwave/usb0/node/9/air_temperature
Example answer:
$ curl -s -X GET -H "X-API-Key:$TOKEN" https://lynx.iotopen.se/api/v2/status/16?topics=obj/zwave/usb0/node/9/air_temperature | jq
[
{
"client_id": 16,
"installation_id": 16,
"timestamp": 1737011284.733,
"value": 21.3,
"topic": "obj/zwave/usb0/node/9/air_temperature",
"msg": ""
}
]
I hope this helps!