Reshenie DataStone API reference
DataStone exposes an HTTP API for configuring devices, data streams, event logs, retention, Hamachi, WebRTC terminal access, and AI model uploads.
Base URL and authentication
| Item | Value |
|---|---|
| API base path | /api/ |
| Content type | application/json, except upload endpoints that use multipart/form-data |
| Admin/session auth | Admin UI session cookie for logged-in staff or superusers |
| API key auth | Authorization: ApiKey <KEY> or X-API-Key: <KEY> |
| Health checks | /healthz/ and /readyz/, outside /api/ |
API keys are scope-based. A write scope also satisfies the matching read scope for that resource.
| Resource | Read scope | Write scope |
|---|---|---|
| Devices | device:read | device:write |
| Data streams | data:read | data:write |
| Data groups | group:read | group:write |
| Values | value:read | value:write |
| Statistics | statistic:read | statistic:write |
| Event logs | event-log:read | event-log:write |
| System endpoints | system:read | system:write |
| WebRTC terminal grant | - | webrtc-terminal:write |
API keys may also restrict allowed device and data IDs. Restricted keys only see permitted devices, data streams, values, statistics, and event logs.
Common conventions
Timestamps accept ISO-8601 strings or UNIX epoch seconds.
| Query parameter | Applies to | Description |
|---|---|---|
from | values, statistics, event logs | Inclusive lower timestamp bound. |
to | values, statistics, event logs | Inclusive upper timestamp bound. |
limit | list endpoints | Maximum rows when no range filter is supplied. Defaults to 100. |
data | values, statistics | Filter by data stream ID. |
When from or to is present on high-volume value/statistic list endpoints, responses may be streamed as a JSON array.
Devices
| Method | Path | Scope | Description |
|---|---|---|---|
GET | /api/device/ | device:read | List devices. |
POST | /api/device/ | device:write | Create a device. |
GET | /api/device/:id/ | device:read | Retrieve a device. |
PATCH, PUT | /api/device/:id/ | device:write | Update a device. |
DELETE | /api/device/:id/ | device:write | Delete a device. |
GET | /api/device/:id/opcua/ | device:read | Browse an OPC-UA device address space. |
GET | /api/device/:id/io/:register/ | device:read | Read directly from a PLC/device address. |
POST | /api/device/:id/io/:register/ | device:write | Write directly to a PLC/device address. |
/io/:register/ supports MELSEC, FEnet, Modbus, and OPC-UA. The register path is a single URL segment; URL-encode any slash characters.
| Query parameter | Description |
|---|---|
type | Data type for MELSEC, FEnet, and Modbus. Defaults to uint16. Supported values include bit, byte, uint16, int16, uint32, int32, uint64, int64, fp16, fp32, and fp64. |
byteorder | little or big for writes. Defaults to little. |
curl -H "Authorization: ApiKey $DATASTONE_API_KEY" \
"http://datastone.local:8000/api/device/1/io/D16000/?type=int32"
{
"value": 12345
}
curl -X POST \
-H "Authorization: ApiKey $DATASTONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value": 42}' \
"http://datastone.local:8000/api/device/1/io/D16000/?type=int32"
{
"written": true,
"value": 42
}
Data groups
| Method | Path | Scope | Description |
|---|---|---|---|
GET | /api/group/ | group:read | List groups. |
POST | /api/group/ | group:write | Create a group. |
GET | /api/group/:id/ | group:read | Retrieve a group. |
PATCH, PUT | /api/group/:id/ | group:write | Update a group. |
DELETE | /api/group/:id/ | group:write | Delete a group. |
Group responses include a data array containing the IDs of data streams assigned to the group.
Data streams
| Method | Path | Scope | Description |
|---|---|---|---|
GET | /api/data/ | data:read | List data streams. |
POST | /api/data/ | data:write | Create a data stream. |
GET | /api/data/:id/ | data:read | Retrieve a data stream. |
PATCH, PUT | /api/data/:id/ | data:write | Update a data stream. |
DELETE | /api/data/:id/ | data:write | Delete a data stream. |
GET | /api/data/:id/value/ | data:read | List values for one stream. |
POST | /api/data/:id/value/ | data:write | Create or update one value record. |
GET | /api/data/:id/statistic/ | data:read | List statistics for one stream. |
POST | /api/data/:id/statistic/ | data:write | Create or update one statistic record. |
GET | /api/data/:id/policy/retention/ | system:read | Read per-stream retention policies. |
POST, PUT | /api/data/:id/policy/retention/ | system:write | Create or update a per-stream retention policy. |
Create a stream:
curl -X POST \
-H "Authorization: ApiKey $DATASTONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Motor RPM","device":1,"path":"D16000","type":"int32"}' \
"http://datastone.local:8000/api/data/"
Read recent values:
curl -H "Authorization: ApiKey $DATASTONE_API_KEY" \
"http://datastone.local:8000/api/data/10/value/?limit=2"
[
{
"data": 10,
"timestamp": "2026-04-28T12:00:00Z",
"value": 1200.5
}
]
Post one value:
curl -X POST \
-H "Authorization: ApiKey $DATASTONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"timestamp":"2026-04-28T12:00:00Z","value":1200.5}' \
"http://datastone.local:8000/api/data/10/value/"
Statistics support a fields query parameter. By default only mean is returned; pass comma-separated values from rms, median, min, max, q1, q3, or all.
curl -H "Authorization: ApiKey $DATASTONE_API_KEY" \
"http://datastone.local:8000/api/data/10/statistic/?from=2026-04-28T00:00:00Z&to=2026-04-29T00:00:00Z&step=PT1H"
step must be an ISO-8601 duration and requires both from and to. Step responses aggregate mean, min, and max into bucketed records.
Values and statistics
Use these top-level endpoints when you need values or statistics across data streams.
| Method | Path | Scope | Description |
|---|---|---|---|
GET | /api/value/?data=&from=&to=&limit= | value:read | List value records. |
GET | /api/value/:id/ | value:read | Retrieve one value record. |
GET | /api/statistic/?data=&from=&to=&limit=&fields= | statistic:read | List statistic records. |
GET | /api/statistic/:id/ | statistic:read | Retrieve one statistic record. |
Event logs
| Method | Path | Scope | Description |
|---|---|---|---|
GET | /api/event-log/?device=&kind=&from=&to=&limit= | event-log:read | List event logs. |
POST | /api/event-log/ | event-log:write | Create an event log. |
GET | /api/event-log/:id/ | event-log:read | Retrieve an event log. |
PATCH, PUT | /api/event-log/:id/ | event-log:write | Update an event log. |
DELETE | /api/event-log/:id/ | event-log:write | Delete an event log. |
POST | /api/event-log/:id/process/ | event-log:write | Fetch the log URL and parse it with optional CSS selectors. |
curl -X POST \
-H "Authorization: ApiKey $DATASTONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"selector":"#price","attr":"data-value"}' \
"http://datastone.local:8000/api/event-log/55/process/"
Hamachi
| Method | Path | Scope | Description |
|---|---|---|---|
GET | /api/hamachi/ | system:read | Return parsed Hamachi client status. |
GET | /api/hamachi/network/ | system:read | List joined Hamachi networks. |
POST | /api/hamachi/network/ | system:write | Join a network with network and optional password. |
DELETE | /api/hamachi/network/ | system:write | Leave a network supplied as network in body or query string. |
GET | /api/hamachi/network/:network_id/ | system:read | Retrieve one joined network. |
DELETE | /api/hamachi/network/:network_id/ | system:write | Leave one network. |
License, terminal, retention, and AI
| Method | Path | Scope | Description |
|---|---|---|---|
GET | /api/license/activation-request/ | system:read | Return the local activation request payload used to issue a license. |
POST | /api/webrtc/terminal-grant/ | webrtc-terminal:write | Issue a short-lived terminal grant token. |
GET | /api/retention/ | system:read | Read data retention policies for core_value and core_valuestatistics. |
POST | /api/retention/ | system:write | Create, update, or remove a data retention policy. |
POST | /api/ai/upload/ | system:write | Upload a TFLite model and scaler, then attach or provision AI device/data records. |
Terminal grant payload:
{
"terminal_id": "edge-01-shell",
"host_id": "edge-01",
"interactive": true,
"allowed_presets": ["journal", "status"]
}
Retention payload:
{
"hypertable": "core_value",
"drop_after_days": 30
}
Set drop_after_seconds, drop_after_hours, or drop_after_days to a positive value. A non-positive value removes the retention policy.
AI upload payload is multipart/form-data:
| Field | Required | Description |
|---|---|---|
model | Yes | .tflite file. |
scaler | Yes | .joblib or .pkl scaler file. |
model_type | Yes | cnn_ae, lstm_ae, or sisvae. |
source | Yes | Source data stream ID. |
threshold | No | Numeric anomaly threshold. |
name | No | AI device name. Defaults to AI Device. |
device_id | No | Existing AI device ID to reuse. |
data_id | No | Existing destination data stream ID to reuse. |
Health checks
| Method | Path | Description |
|---|---|---|
GET | /healthz/ | Liveness check. |
GET | /readyz/ | Readiness check. Defaults to database check. |
GET | /readyz/?checks=db,redis | Run selected readiness checks. |