Variable Object

Describes the JSON object of a Variable.

A Variable in Ubidots can store one or more data points. Variables are the most granular entity and can either be raw (sensor or manually sent data) or synthetic (computed from an expression using other variables).

PropertyTypeDescription
idStringID of Variable
labelStringLabel of Variable
nameStringName of Variable
descriptionStringDescription of Variable
deviceObjectThe Device this Variable belongs to. Contains id, label, name, url, and createdAt.
tagsString ArrayTags of Variable
propertiesObjectProperties of Variable. See Properties object below.
typeStringVariable type. Can be raw or synthetic. See Variable Types below.
unitStringUnit of measurement for the Variable (e.g. °C, m/s, %). Can be null.
syntheticExpressionStringMathematical expression used to compute the variable's value. Only applicable when type is synthetic. Empty string for raw variables.
createdAtStringDate the Variable was created (ISO 8601 format).
lastValueObjectThe most recent data point sent to the Variable. See lastValue object below.
lastActivityNumberUnix timestamp (ms) of the Variable's last recorded activity. Can be null if no data has been received.
urlStringURL of Variable
valuesUrlStringURL to access the Variable's historical data points via the v1.6 API.

Variable

{
    "url": "https://industrial.api.ubidots.com/api/v2.0/variables/67253b189bcbc904dc48cd4c",
    "id": "67253b189bcbc904dc48cd4c",
    "label": "temp",
    "name": "Temperature",
    "description": "",
    "device": {
        "url": "https://industrial.api.ubidots.com/api/v2.0/devices/67253b189bcbc904dc48cd4d",
        "id": "67253b189bcbc904dc48cd4d",
        "label": "614385e15e4b40df8ecba871629a3c08",
        "name": "Itagüí",
        "createdAt": "2024-11-01T20:33:28.202904Z"
    },
    "tags": [],
    "properties": {
        "_icon": "thermometer-half",
        "_color": "#e9c46a",
        "_previous_variable_label": "temp"
    },
    "type": "raw",
    "unit": "°C",
    "syntheticExpression": "",
    "createdAt": "2024-11-01T20:33:28.319179Z",
    "lastValue": {
        "value": 17.84,
        "timestamp": 1771878262000,
        "context": {},
        "created_at": 1771878563537
    },
    "lastActivity": 1771878563539,
    "valuesUrl": "https://industrial.api.ubidots.com/api/v1.6/variables/67253b189bcbc904dc48cd4e/values"
}

Variable Types

The type field determines how a variable receives its value:

  • raw: The variable stores data points sent directly from a device or external source (e.g. sensors, API calls). The syntheticExpression field will be an empty string.
  • synthetic: The variable's value is automatically computed from a mathematical expression referencing other variables (indicated by {{variable_id}} placeholders in syntheticExpression). Synthetic variables do not receive raw data.

Synthetic variable example:

{
    "type": "synthetic",
    "syntheticExpression": "{{67253b189bcbc904dc48cd51}} * {{67253b189bcbc904dc48cd4f}}"
}

Properties object

The properties key object describes the following about a Variable:

  • Color.
  • Icon.
  • Timezone for data aggregation.
PropertyTypeDescription
_iconStringFont Awesome v6.1.1 icon name assigned to the variable. For example, "thermometer-half".
_colorStringVariable color in hexadecimal format. For example, "#e9c46a".
timezoneStringTimezone used for data aggregation and display. Uses IANA timezone format. For example, "America/Bogota".

Properties object example

{
    "properties": {
        "_icon": "thermometer-half",
        "_color": "#e9c46a",
        "timezone": "America/Bogota",
    }
}

lastValue object

The lastValue object contains the most recent data point recorded for the Variable. It will be an empty object {} if no data has been received yet.

PropertyTypeDescription
valueNumberThe numeric value of the last data point.
timestampNumberUnix timestamp (ms) indicating when the value was measured or originated.
contextObjectArbitrary key-value pairs sent alongside the value for additional metadata (e.g. cardinal direction, icon URLs). Can be an empty object {}.
created_atNumberUnix timestamp (ms) indicating when the data point was stored in Ubidots.

lastValue object example

{
    "lastValue": {
        "value": 10.0,
        "timestamp": 1771878262000,
        "context": {
            "cardinal_direction": "N"
        },
        "created_at": 1771878563540
    }
}