v0.62.0
ReferenceClient librariesQuick start

Quick start

Install the Python or TypeScript client, connect to a Synnax Core, and write and read your first samples.

In this tutorial, you write a script that stores five pressure samples in a Synnax Core and reads them back. It takes about five minutes. Each step adds code to one file: quick_start.py for Python or quick_start.ts for TypeScript. Do not name the Python file synnax.py, because that name hides the synnax package.

You need:

  • Synnax Desktop open on your computer. You can also use a Core in Synnax Enterprise that your computer can reach, with a username and password for it.
  • Python 3.13 or later, or Node.js 22.12 or later.

Install the client

pip install synnax

Install the client version that matches the major and minor version of your Core, such as client 0.61 for Core 0.61. The client prints a warning when the versions differ, and the TypeScript client can stop with an error. The Connect from code dialog of Synnax Desktop gives the install command that matches. To open it, click the code button in the top bar of Synnax Desktop.

Install without internet access

If the computer for your script has no internet access, download the Python client and its dependencies on a computer that does. Use a computer with the same operating system, CPU architecture, and Python version. Replace 0.61 with the major and minor version of your Core:

pip download "synnax==0.61.*" -d synnax-wheels

Copy the synnax-wheels folder to the computer with no internet access, then install from it:

pip install --no-index --find-links synnax-wheels synnax

Do not download with --platform for a different operating system. pip then skips the dependencies that only that operating system needs, and the install fails.

Connect to the Core

With Synnax Desktop open, the Python client finds its Core by itself:

import synnax as sy

client = sy.Synnax()

For a Core in Synnax Enterprise, give its address and your credentials:

client = sy.Synnax(
    host="core.example.com",
    port=9090,
    username="operator",
    password="secret",
)

For TLS, API keys, and other options, see Connect to a Core.

Create two channels

The samples go in a data channel, and their timestamps go in an index channel. For more about channels, see Create channels.

time = client.channels.create(
    name="tank_time",
    data_type=sy.DataType.TIMESTAMP,
    is_index=True,
    retrieve_if_name_exists=True,
)
pressure = client.channels.create(
    name="tank_pressure",
    data_type=sy.DataType.FLOAT32,
    index=time.key,
    retrieve_if_name_exists=True,
)

Write five samples

Write one sample every 100 milliseconds, starting now:

start = sy.TimeStamp.now()
client.write(
    start,
    {
        "tank_time": [
            start + sy.TimeSpan.MILLISECOND * 100 * i for i in range(5)
        ],
        "tank_pressure": [20.0, 20.5, 21.0, 21.5, 22.0],
    },
)

Read the samples back

samples = client.read(
    sy.TimeRange(start, start + sy.TimeSpan.SECOND),
    "tank_pressure",
)
print(samples.to_numpy())
client.close()

Run the script

python quick_start.py

The script prints the five samples that it wrote:

[20.  20.5 21.  21.5 22. ]

When the channels exist, the script uses them, so you can run it again.

Next steps

  • Series and frames -> work with the data that a read returns.
  • Write data -> write samples as they arrive with a writer.
  • Read data -> read many channels, the latest samples, or large time ranges.
  • Stream data -> get samples live, as the Core receives them.