Skip to main content

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:

ParamDescription
deviceIdUUID of the device
pinVirtual pin number (0–255)

Query params:

ParamTypeDefaultDescription
fromISO 86011 hour agoStart timestamp
toISO 8601nowEnd timestamp
limitnumber1000Max data points returned
aggregateraw | avg | min | max | sumrawAggregation function
interval1m | 5m | 1h | 1dTime bucket size (required for non-raw)
formatjson | csvjsonResponse 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"
}
  • timestamp is 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:

ParamDescription
fromDelete data from this timestamp
toDelete 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.