REST API and Python
The Scadora server offers its data to programs through a simple REST API: reading and writing tags, history, alarms and acknowledgement. Python scripts, MES, Excel (Power Query), Node-RED and any program that speaks HTTP and JSON can use it.
API token
Section titled “API token”A program signs in with an API token, not a password. An administrator issues it:
- In the editor, open Project → Users and roles on the server.
- Select a user and press API tokens…. It is convenient to create a separate user for a program, for example
meswith the Viewer or Operator role. - Enter a name (“Python, QA report”) and a validity period, press Issue token and copy it right away. The server keeps only a hash of the token, so it cannot be shown again.
- Permissions. A token has its user’s permissions: only allowed tag tables and alarm areas are visible. Writing needs the Operate permission, and parameter tags also need Write parameters.
- Audit log. Every write and acknowledgement goes to the audit log marked “(API)”.
- Revoking. “Revoke selected” disables a token at once. If the user is disabled or deleted, their tokens stop working too.
- Electronic signature. Tags that need a signature cannot be written over the API, only from the operator station.
Endpoints
Section titled “Endpoints”The API runs on the server’s web port (5101 by default): https://<server>:5101/api/v1/…. Every request needs the header Authorization: Bearer <token>.
| Method | Path | What it does |
|---|---|---|
| GET | /api/v1/me |
Who the token belongs to and its permissions |
| GET | /api/v1/tags?filter=Tank* |
Tags with current values, quality and time |
| GET | /api/v1/tags/{name} |
One tag |
| POST | /api/v1/tags/read |
Values of several tags: {"names": ["Tank1.Level", "Pump1.Run"]} |
| PUT | /api/v1/tags/{name} |
Write: {"value": 42.5} |
| GET | /api/v1/history/{name}?from=…&to=…&maxPoints=500 |
Archived values, time in ISO 8601 |
| GET | /api/v1/alarms?area=… |
Active and unacknowledged alarms |
| POST | /api/v1/alarms/ack |
Acknowledge: {"names": ["Tank1_High"]} or {"all": true} |
The server provides the full OpenAPI 3 description at /api/v1/openapi.json, which you can open in Postman or Swagger Editor. The /api/v1/docs page lists the endpoints with examples and works without internet access.
Errors come with an HTTP status and a message in the detail field: 401 — no token or it is invalid, 403 — no permission, 404 — the tag does not exist or is not visible to the user, 409 — the device refused the write.
Python
Section titled “Python”The scadora package uses only the standard library and works on Python 3.8 and later.
from scadora import Scadora
scada = Scadora("https://scada-server:5101", token="sct_...", verify="scadora-server.cer")
print(scada.read("Tank1.Level"))print(scada.read_many(["Tank1.Level", "Pump1.Run"]))for tag in scada.tags("Tank*"): print(tag.name, tag.value, tag.unit, tag.good)
scada.write("Tank1.Setpoint", 42.5)
for s in scada.history("Tank1.Level", hours=24, max_points=500): print(s.time, s.value)
scada.acknowledge(["Tank1_High"])Certificate. The server encrypts traffic with its own certificate. Download it from https://<server>:5101/scadora-server.cer and pass the path as verify. If you connect by an address that is not in the certificate (for example, by IP), add check_hostname=False. verify=False turns the check off — for test benches only.
curl -H "Authorization: Bearer sct_..." https://scada-server:5101/api/v1/tags?filter=Tank*curl -X PUT -H "Authorization: Bearer sct_..." -H "Content-Type: application/json" \ -d "{\"value\": 42.5}" https://scada-server:5101/api/v1/tags/Tank1.Setpoint