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).
| Property | Type | Description |
|---|---|---|
| id | String | ID of Variable |
| label | String | Label of Variable |
| name | String | Name of Variable |
| description | String | Description of Variable |
| device | Object | The Device this Variable belongs to. Contains id, label, name, url, and createdAt. |
| tags | String Array | Tags of Variable |
| properties | Object | Properties of Variable. See Properties object below. |
| type | String | Variable type. Can be raw or synthetic. See Variable Types below. |
| unit | String | Unit of measurement for the Variable (e.g. °C, m/s, %). Can be null. |
| syntheticExpression | String | Mathematical expression used to compute the variable's value. Only applicable when type is synthetic. Empty string for raw variables. |
| createdAt | String | Date the Variable was created (ISO 8601 format). |
| lastValue | Object | The most recent data point sent to the Variable. See lastValue object below. |
| lastActivity | Number | Unix timestamp (ms) of the Variable's last recorded activity. Can be null if no data has been received. |
| url | String | URL of Variable |
| valuesUrl | String | URL 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). ThesyntheticExpressionfield 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 insyntheticExpression). 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.
| Property | Type | Description |
|---|---|---|
_icon | String | Font Awesome v6.1.1 icon name assigned to the variable. For example, "thermometer-half". |
_color | String | Variable color in hexadecimal format. For example, "#e9c46a". |
timezone | String | Timezone 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.
| Property | Type | Description |
|---|---|---|
| value | Number | The numeric value of the last data point. |
| timestamp | Number | Unix timestamp (ms) indicating when the value was measured or originated. |
| context | Object | Arbitrary key-value pairs sent alongside the value for additional metadata (e.g. cardinal direction, icon URLs). Can be an empty object {}. |
| created_at | Number | Unix 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
}
}
