Examples
Runnable Python and TypeScript scripts that write, read, and stream data, run control sequences, and set up hardware tasks.
Each example is a script in the Synnax repository that you can run against your own Core.
Run an example
Python
TypeScript
Most Python examples create the client with sy.Synnax(). With Synnax Desktop open,
they connect to it with no setup. To run them against a Core in Synnax Enterprise, log
in once with sy login, see
Log in once with sy login. Then
run a script:
python basic_read_write.pyThe Arduino examples set their connection values in the script.
The control examples and the simulators import other example files. Run them as modules
from the client/py folder, with a simulator in a second terminal:
python -m examples.simulators.press
python -m examples.control.press.control_sequenceThe README in each folder gives the steps.
The TypeScript examples connect to localhost:9090 with the username synnax and the
password seldon. Replace these values in the script. For Synnax Desktop, use the
host, port, and apiKey from the Connect from code dialog, see
Connect to Synnax Desktop. For a
Core in Synnax Enterprise, use its address and your credentials.
From the client/ts/examples/node folder, install the client that matches the version
of your Core, then run a script. Change 0.61 to the major and minor version of your
Core:
npm install
npm install @synnaxlabs/client@~0.61.0
node basicReadWrite.jsstreamRead.js streams the samples that streamWrite.js writes. Run streamWrite.js
first, in a second terminal.
Examples by topic
Python
TypeScript
Write, read, and work with data. See Write data and Read data.
Stream data. See Stream data. The scripts that read
live samples need stream_write.py to run in a second terminal.
Channels and ranges. See Channels and Ranges.
Control sequences. See Control.
Hardware tasks. See Hardware. These examples need the device and the Driver. MQTT tasks run in the Core, so the MQTT examples need no Driver. The Modbus, OPC UA, HTTP, and MQTT folders include a simulated device.
Write, read, and work with data. See Write data and Read data.
Stream data. See Stream data.