Ubidots Community

[SOLVED] Get a value with http request

hi,
with the following URL:
http://things.ubidots.com/api/v1.6/devices/mydevice/myvar/values/?page_size=1&token=token
we get :
{
“url”: “http://things.ubidots.com/api/v1.6/values/573644685753c902de57d125”,
value”: 21.21,
“timestamp”: 1463174248257,
“context”: {“lat”: 1.12, “lng”: 2.019},
“created_at”: “2016-05-13T21:17:28.257”},
]

How to get only the “value” (21.21) directly.

Hi @Mehdi.Imed,

In HTTP is not posible for now, but you can do it with MQTT, here is an example:

/v1.6/devices/{LABEL_DATA_SOURCE}/{LABEL_VARIABLE}/lv: This will return the last value of the variable as a single float value. This makes it easier to parse in microcontrollers.

In our documentation you can find more information about MQTT https://ubidots.com/docs/api/mqtt.html#subscribe-to-a-variable

All the best,
kath :smile: