REST API GET value for a single resource


#1

Hi,

I’ve a device that has 3 resources (Temp, Hum and HeatIdx). Is there a way through HTTP GET to get the value of, for instance the TEMP?

Currently I’ve tried the following:

https://api.thinger.io/v2/users/xxx/devices/yyy/dht22?authorization=***

And I’m getting protoson code for the 3 resources:

{"out":{"humidity":99.9,"temperature":12.3,"heat_index":12.1939}}

The goal is to get only individual readings so I can pass it to an Android Widget.

Thank you


#2

Hi,

in this case, just create a single resource for each reading (humidity, and temperature), like:

thing["humidity"] >> [](pson& out){
    out = dht.readHumidity();
};

thing["temperature"] >> [](pson& out){
    out = dht.readTemperature();
};

And just query each resource indiviually:

https://api.thinger.io/v2/users/xxx/devices/yyy/temperature?authorization=***

Hope it helps!