Data API
The Data API provides access to all historical pin values stored by VWire. Use it to run analytics, export data, or push data from non-MQTT sources.
Read pin data
GET /api/v1/data/{deviceId}/{pin}
Path params:
| Param | Description |
|---|---|
deviceId | UUID of the device |
pin | Virtual pin number (0–255) |
Query params:
| Param | Type | Default | Description |
|---|---|---|---|
from | ISO 8601 | 1 hour ago | Start timestamp |
to | ISO 8601 | now | End timestamp |
limit | number | 1000 | Max data points returned |
aggregate | raw | avg | min | max | sum | raw | Aggregation function |
interval | 1m | 5m | 1h | 1d | — | Time bucket size (required for non-raw) |
format | json | csv | json | Response format |
Example:
GET /api/v1/data/uuid/0?from=2024-03-15T00:00:00Z&to=2024-03-15T23:59:59Z&aggregate=avg&interval=1h
Response (JSON):
{
"success": true,
"data": {
"pin": 0,
"deviceId": "uuid",
"points": [
{ "timestamp": "2024-03-15T00:00:00Z", "value": 23.4 },
{ "timestamp": "2024-03-15T01:00:00Z", "value": 23.7 }
]
}
}
Response (CSV):
timestamp,value
2024-03-15T00:00:00Z,23.4
2024-03-15T01:00:00Z,23.7
Write pin data
Push data to a device pin without MQTT. Useful for HTTP-based devices, scripts, or testing.
POST /api/v1/data/{deviceId}/{pin}
Content-Type: application/json
{
"value": "23.5",
"timestamp": "2024-03-15T10:30:00.000Z"
}
timestampis optional; defaults to server time- Writing triggers the same pipeline as MQTT (real-time dashboard updates, notification rules, etc.)
Bulk write
Write multiple pin values in one request:
POST /api/v1/data/{deviceId}/bulk
Content-Type: application/json
{
"readings": [
{ "pin": 0, "value": "23.5" },
{ "pin": 1, "value": "61" },
{ "pin": 2, "value": "1013" }
]
}
Latest value
Get the most recent value for a pin:
GET /api/v1/data/{deviceId}/{pin}/latest
Response:
{
"success": true,
"data": {
"value": "23.5",
"timestamp": "2024-03-15T10:30:00.000Z"
}
}
Delete pin data
DELETE /api/v1/data/{deviceId}/{pin}
Query params:
| Param | Description |
|---|---|
from | Delete data from this timestamp |
to | Delete data up to this timestamp |
Omit both to delete all data for the pin.
caution
Data deletion is permanent. Use from/to to delete specific ranges.