Return value of GET on v1/devices/{DEVICE_ID}/{VARIABLE_NAME}

I have read the documentation of the Cloud API, but I couldn’t find what the response format of the json returned when doing a GET request to read the value of a variable.

I am writing the Golang bindings for the API, but haven’t yet managed to get hold of a Spark Core. Thus at the moment there is no way of knowing what is the response.

I am hitting the following endpoint:

v1/devices/{DEVICE_ID}/{VARIABLE_NAME}?access_token=abcd1234

Thanks!

Hi @dhanush

It returns a JSON like this:

{
  "cmd": "VarReturn",
  "name": "<<your variable name here>>",
  "result": <<your variable value here>>,
  "coreInfo": {
    "last_app": "",
    "last_heard": "2014-07-27T16:45:42.803Z",
    "connected": true,
    "deviceID": "<<your device id here>>"
  }

I edited the parts between the << >> to where your specific values will be. Variables can be strings or integers or double-precision floating-point numbers or booleans.

3 Likes

Thanks for your response @bko. What does last_app mean here? In case it is not an empty string, what would it look like then?

I think that is supposed to be the name of the last sketch you loaded but it does not appear to implemented yet.

1 Like