Skip to content

Developers

Build on Scadex.

Scadex is a core you can build on. It has a documented SCADA API, a TypeScript SDK with React hooks for your own screens, and a module contract for your own drivers and plugins.

The stack

Your app, the API, the core and the modules.

Everything sits inside your own network. Your code talks to the core through the SDK or the API, and drivers and plugins are modules that plug into the core.

Your app or toolA React screen, a script, a report, another systemSDKTypeScript, with React hooksREST and WebSocket APIRoles and API keysScadex CoreTags, alarms, security and replay.It loads, starts and stops the modules.DriversOPC UA, Modbus, MQTTPluginsHistorian, scriptsYour modulesThe same contractYour app or toolA React screen, a script, a reportSDKTypeScript,React hooksAPIREST andWebSocketScadex CoreTags, alarms, security, replay.Loads and stops the modules.DriversOPC UA,MQTTPluginsHistorian,scriptsYoursSamecontract

API

A documented SCADA API.

The gateway serves a JSON API under /api/v1, the same API the dashboard uses, and one WebSocket for live values and alarms.

  • What it covers. Tags and tag types, alarms and their history, screens, history, modules, connections, users and API keys.
  • Who may call it. A person signs in and the gateway keeps a session. A program uses an API key with the viewer, operator or engineer role. Admin keys cannot exist, and the role is checked on the server for every request.
  • The live feed. One WebSocket carries tag values as they change, writes, replay and alarm frames. It uses a signed-in session: an API key is for REST.
Shell · read a tag over REST
curl -H "Authorization: Bearer <api key>" \
  https://<your gateway>/api/v1/runtime/tags/Plant.Line1.Setpoint/current
JSON frames · subscribe on the live socket
// open wss://<your gateway>/sync with a signed-in session, then send
{"event": "tag.subscribe", "data": {"path": "Plant.Tank1.Level"}}
// the gateway answers with a tag.value frame now, and again on every change

SDK

A SCADA SDK for TypeScript, with React hooks.

The SDK is the client the dashboard itself is built on: a REST client, the live socket with reconnection and replay, and React hooks for your own screens.

  • The core has no React in it. The package's main entry is a client that any framework can use in the browser. The React hooks are an optional extra entry, @scadex.io/sdk/react, for React 18.
  • Other frameworks. React comes first. No other framework has bindings today, and none is promised here.
  • The package. It is not on npm yet. You add it to your project as a package, and the guide shows how. Your page and the gateway share an origin, with /api and /sync passed on to the gateway.
  • In use. One operator page runs on it today.
React (TSX) · LevelCard.tsx
import { useTag } from "@scadex.io/sdk/react";

export function LevelCard() {
  const level = useTag<number>("Plant.Tank1.Level");
  if (level.loading) return <p>Waiting for the gateway</p>;

  return (
    <section aria-label="Tank 1 level">
      <h2>{level.formattedValue ?? `${level.value} ${level.unit ?? ""}`}</h2>
      {!level.good && <p role="status">Do not trust this value: {level.qualityDetail ?? level.quality}</p>}
      {level.replayed && <p>This is the past, replayed. It is not the plant now.</p>}
    </section>
  );
}

The hooks

ScadexProvider
Connects the live socket when it mounts and disconnects when it unmounts. Mount it once, around the signed-in part of the app.
useClient
The client and the state of the connection: connecting, connected, disconnected or error.
useTag
One tag: its value, unit, quality, whether it is replayed from the past, and a write that says when it is pending.
useTags
The list of tags.
useTagValues
The latest value of many tags, one subscription each.
useAlarms
The active alarms, how many there are, and acknowledge.
useReplay
Where a replay is, for a clock.
useReplaySelector
The same, re-drawing only when the part you picked changes.
useAuth
Whether the person is signed in, from the gateway's own session.

Modules

Custom SCADA drivers and plugins, on a module contract.

Every driver and plugin in Scadex is a module: a package with its own version, its own licence and its own log, which the gateway can start, stop, install and remove while it runs.

What a module can do

  • Publish values for the tags it owns, and handle writes to them.
  • Declare its own routes under /api/v1/modules/<module id>/. The core owns the namespace and the role each route needs.
  • Keep state: key and JSON entries the gateway stores for it, encrypted, and includes in backups. It also has a private data directory.
  • Run scripts in the gateway's sandbox, and receive tag changes, alarm changes and messages as events.
  • Describe a connection form, so the dashboard can draw it without knowing the technology (a driver).

How it is built and kept

  • A folder. A C# project, a licence file and a module.json. Modules run as trusted code inside the gateway.
  • A versioned contract. A module names the contract version it was built against, as major and minor. It loads on a gateway with the same major and the same or a newer minor, and the gateway reads this before it runs any of its code.
  • Stopped and started. A module is written to be stopped and started while the gateway runs. One that fails to load is reported as failed, and the gateway and the other modules carry on.
  • Its own licence. Each module carries its own licence terms, and a module can require a signed licence to load.
  • The same contract for ours. The drivers Scadex ships are modules too. They are the worked examples: OPC UA, Modbus TCP, MQTT and Telegraf.

The module contract is not published to a package feed yet.

JSON · module.json of the MQTT driver
{
  "id": "io.scadex.driver.mqtt",
  "name": "MQTT Driver",
  "version": "1.0.0",
  "vendor": "scadex.io",
  "license": "LicenseRef-Scadex-Proprietary",
  "sdkVersion": "1.2",
  "requiresLicense": false,
  "assembly": "Scadex.Modules.Mqtt.dll"
}

Scripting and events

Scripts, event streams and webhooks.

When you do not need a module, a script or a stream is enough: react to a tag, a schedule or an alarm, and tell another system.

Scripts
JavaScript in a sandbox beside the gateway, with a system.* API for tags, alarms, databases, the gateway, users, dates and small helpers.
Triggers
A job's script runs on a clock time, an interval, a tag change, an alarm, a message, startup or shutdown.
Event streams
Batches of tag changes sent to a webhook as JSON, or to InfluxDB as line protocol, with a delivery log and retries.
Alarm pipelines
A webhook call when an alarm goes active, is acknowledged or clears, from a minimum severity.
JavaScript · a job script
writeTag('Reports.Shift.EndLevel', tag('Plant.Tank1.Level'));
writeTag('Reports.Shift.EndLevelAt', system.date.format(system.date.now()));

What stays yours

Your data, your hardware, and a way out.

Your data and your hardware

Values, history and configuration stay on your own server, inside your network. The gateway runs without the internet, and the only thing we see is a short hourly check-in that you can turn off.

Standard protocols in and out

OPC UA, Modbus TCP and MQTT come in, and Telegraf agents push in. Values go out as MQTT topics, as a Modbus TCP server, over REST, to webhooks and to InfluxDB.

The ability to leave

Export tags and tag types as files, download a backup of the gateway's database, and read history through the API. A backup holds the database; the historian's own file and the keys are kept beside it.

Ready to build on it?

Read the guides, or tell us what you want to build and we answer in plain language.