# 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](https://docs.synnaxlabs.com/reference/get-started/install-desktop) on your computer, or a Core in [Synnax Enterprise](https://docs.synnaxlabs.com/reference/enterprise) that your computer can reach, and a username and password for it.
* Python 3.12 or later, or Node.js 22 or later.

## Install the client

[Enterprise](https://docs.synnaxlabs.com/reference/get-started/editions "Needs Synnax Enterprise")

**Python**

```bash
pip install synnax
```

**TypeScript**

The script uses top-level await, so make an ES module project:

```bash
npm init -y
npm pkg set type=module
npm install @synnaxlabs/client tsx
```

Install the client version that matches the major and minor version of your Core, such as client 0.58 for Core 0.58. The client prints a warning when the versions differ.

## Connect to the Core

Replace the address and credentials with the values of your Core. For TLS and other options, see [Connect to a Core](https://docs.synnaxlabs.com/reference/client/connect).

With Synnax Desktop, the Python client finds the Core by itself: call `sy.Synnax()` with no arguments. For TypeScript, copy the code from the **Connect from code** dialog. See [Connect to Synnax Desktop](https://docs.synnaxlabs.com/reference/client/connect#connect-to-synnax-desktop).

[Enterprise](https://docs.synnaxlabs.com/reference/get-started/editions "Needs Synnax Enterprise")

**Python**

```python
import synnax as sy

client = sy.Synnax(
    host="localhost",
    port=9090,
    username="synnax",
    password="seldon",
)
```

**TypeScript**

```typescript
import { DataType, Synnax, TimeSpan, TimeStamp } from "@synnaxlabs/client";

const client = new Synnax({
  host: "localhost",
  port: 9090,
  username: "synnax",
  password: "seldon",
});
```

## 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](https://docs.synnaxlabs.com/reference/channels/create).

[Enterprise](https://docs.synnaxlabs.com/reference/get-started/editions "Needs Synnax Enterprise")

**Python**

```python
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,
)
```

**TypeScript**

```typescript
const time = await client.channels.create(
  { name: "tank_time", dataType: DataType.TIMESTAMP, isIndex: true },
  { retrieveIfNameExists: true },
);
const pressure = await client.channels.create(
  { name: "tank_pressure", dataType: DataType.FLOAT32, index: time.key },
  { retrieveIfNameExists: true },
);
```

## Write five samples

Write one sample every 100 milliseconds, starting now:

[Enterprise](https://docs.synnaxlabs.com/reference/get-started/editions "Needs Synnax Enterprise")

**Python**

```python
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],
    },
)
```

**TypeScript**

```typescript
const start = TimeStamp.now();
const step = TimeSpan.milliseconds(100);
await client.write(start, {
  tank_time: [0, 1, 2, 3, 4].map((i) => start.add(step.mult(i))),
  tank_pressure: [20.0, 20.5, 21.0, 21.5, 22.0],
});
```

## Read the samples back

[Enterprise](https://docs.synnaxlabs.com/reference/get-started/editions "Needs Synnax Enterprise")

**Python**

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

**TypeScript**

```typescript
const samples = await client.read(
  { start, end: start.add(TimeSpan.seconds(1)) },
  "tank_pressure",
);
console.log(Array.from(samples));
await client.close();
```

## Run the script

[Enterprise](https://docs.synnaxlabs.com/reference/get-started/editions "Needs Synnax Enterprise")

**Python**

```bash
python quick_start.py
```

The script prints the five samples that it wrote:

```plaintext
[20.  20.5 21.  21.5 22. ]
```

**TypeScript**

```bash
npx tsx quick_start.ts
```

The script prints the five samples that it wrote:

```plaintext
[ 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](https://docs.synnaxlabs.com/reference/client/series-and-frames) -> work with the data that a read returns.
* [Write data](https://docs.synnaxlabs.com/reference/client/write-data) -> write samples as they arrive with a writer.
* [Read data](https://docs.synnaxlabs.com/reference/client/read-data) -> read many channels, the latest samples, or large time ranges.
* [Stream data](https://docs.synnaxlabs.com/reference/client/stream-data) -> get samples live, as the Core receives them.
