How to get a variable values via Rest API

Hello,

I would like to know how I can get the data contained in a variable to use it in an external web application, using the Ubidots API.

I found out how to send the data by email but not how to get this data directly in response to a REST API request, in JSON object for example?

Thanks

R u looking something like this? Not sure it helps.

Thank you Ali,

I finally found the URL I was looking for to load the data from Ubidots

        variable = make_web_request("GET",
                                    "https://industrial.api.ubidots.com/api/v2.0/devices/{}/variables/~{}".
                                    format(device_id, variable),
                                    headers)

        variable_values = make_web_request("GET",
                                           variable.json()["valuesUrl"] + "?start=" + str(start_date*1000) + "&page_size=150000",
                                           headers
                                           ).json()["results"]

Here, the parameters of the “format” function mean: ‘device_id’ is the ID of the device the variable belongs to and ‘variable’ is the label of the variable I want to load data from

Hi @bertrandgauvreau,

I hope all is well.

The device id is a unique identifier that is used to send data, you can find it on the device vies below the API label.

All the best,
-Isabel

1 Like