Skip to main content

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

ItemValue
API base path/api/
Content typeapplication/json, except upload endpoints that use multipart/form-data
Admin/session authAdmin UI session cookie for logged-in staff or superusers
API key authAuthorization: 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.

ResourceRead scopeWrite scope
Devicesdevice:readdevice:write
Data streamsdata:readdata:write
Data groupsgroup:readgroup:write
Valuesvalue:readvalue:write
Statisticsstatistic:readstatistic:write
Event logsevent-log:readevent-log:write
System endpointssystem:readsystem: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 parameterApplies toDescription
fromvalues, statistics, event logsInclusive lower timestamp bound.
tovalues, statistics, event logsInclusive upper timestamp bound.
limitlist endpointsMaximum rows when no range filter is supplied. Defaults to 100.
datavalues, statisticsFilter 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

MethodPathScopeDescription
GET/api/device/device:readList devices.
POST/api/device/device:writeCreate a device.
GET/api/device/:id/device:readRetrieve a device.
PATCH, PUT/api/device/:id/device:writeUpdate a device.
DELETE/api/device/:id/device:writeDelete a device.
GET/api/device/:id/opcua/device:readBrowse an OPC-UA device address space.
GET/api/device/:id/io/:register/device:readRead directly from a PLC/device address.
POST/api/device/:id/io/:register/device:writeWrite 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 parameterDescription
typeData type for MELSEC, FEnet, and Modbus. Defaults to uint16. Supported values include bit, byte, uint16, int16, uint32, int32, uint64, int64, fp16, fp32, and fp64.
byteorderlittle 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

MethodPathScopeDescription
GET/api/group/group:readList groups.
POST/api/group/group:writeCreate a group.
GET/api/group/:id/group:readRetrieve a group.
PATCH, PUT/api/group/:id/group:writeUpdate a group.
DELETE/api/group/:id/group:writeDelete a group.

Group responses include a data array containing the IDs of data streams assigned to the group.

Data streams

MethodPathScopeDescription
GET/api/data/data:readList data streams.
POST/api/data/data:writeCreate a data stream.
GET/api/data/:id/data:readRetrieve a data stream.
PATCH, PUT/api/data/:id/data:writeUpdate a data stream.
DELETE/api/data/:id/data:writeDelete a data stream.
GET/api/data/:id/value/data:readList values for one stream.
POST/api/data/:id/value/data:writeCreate or update one value record.
GET/api/data/:id/statistic/data:readList statistics for one stream.
POST/api/data/:id/statistic/data:writeCreate or update one statistic record.
GET/api/data/:id/policy/retention/system:readRead per-stream retention policies.
POST, PUT/api/data/:id/policy/retention/system:writeCreate 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.

MethodPathScopeDescription
GET/api/value/?data=&from=&to=&limit=value:readList value records.
GET/api/value/:id/value:readRetrieve one value record.
GET/api/statistic/?data=&from=&to=&limit=&fields=statistic:readList statistic records.
GET/api/statistic/:id/statistic:readRetrieve one statistic record.

Event logs

MethodPathScopeDescription
GET/api/event-log/?device=&kind=&from=&to=&limit=event-log:readList event logs.
POST/api/event-log/event-log:writeCreate an event log.
GET/api/event-log/:id/event-log:readRetrieve an event log.
PATCH, PUT/api/event-log/:id/event-log:writeUpdate an event log.
DELETE/api/event-log/:id/event-log:writeDelete an event log.
POST/api/event-log/:id/process/event-log:writeFetch 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

MethodPathScopeDescription
GET/api/hamachi/system:readReturn parsed Hamachi client status.
GET/api/hamachi/network/system:readList joined Hamachi networks.
POST/api/hamachi/network/system:writeJoin a network with network and optional password.
DELETE/api/hamachi/network/system:writeLeave a network supplied as network in body or query string.
GET/api/hamachi/network/:network_id/system:readRetrieve one joined network.
DELETE/api/hamachi/network/:network_id/system:writeLeave one network.

License, terminal, retention, and AI

MethodPathScopeDescription
GET/api/license/activation-request/system:readReturn the local activation request payload used to issue a license.
POST/api/webrtc/terminal-grant/webrtc-terminal:writeIssue a short-lived terminal grant token.
GET/api/retention/system:readRead data retention policies for core_value and core_valuestatistics.
POST/api/retention/system:writeCreate, update, or remove a data retention policy.
POST/api/ai/upload/system:writeUpload 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:

FieldRequiredDescription
modelYes.tflite file.
scalerYes.joblib or .pkl scaler file.
model_typeYescnn_ae, lstm_ae, or sisvae.
sourceYesSource data stream ID.
thresholdNoNumeric anomaly threshold.
nameNoAI device name. Defaults to AI Device.
device_idNoExisting AI device ID to reuse.
data_idNoExisting destination data stream ID to reuse.

Health checks

MethodPathDescription
GET/healthz/Liveness check.
GET/readyz/Readiness check. Defaults to database check.
GET/readyz/?checks=db,redisRun selected readiness checks.