# Find channels

> Find channels in the Console, or retrieve them in code by name, key, pattern, or search term.

In the Console, you find a [channel](https://docs.synnaxlabs.com/reference/channels) to plot it or to add it to a schematic. In a script, you retrieve a channel before you read or write its data.

## Find a channel in the Console

The [channels toolbar](https://docs.synnaxlabs.com/reference/channels#channels-in-the-console) lists all of the channels in Synnax. To open it, click or press **C**. To add a channel to a schematic, drag it from the toolbar onto the schematic.

To find a channel by name, click at the top of the left bar, or press **Ctrl+P** (**Cmd+P** on macOS), to open the [search palette](https://docs.synnaxlabs.com/reference/get-started/ui-overview#search-and-command-palette). Then type part of the name. Select a result to add the channel to the open line plot, or to a new line plot. A virtual channel opens in a log.

[](https://synnax.nyc3.cdn.digitaloceanspaces.com/docs/client/channels/find/8c96a95d9bd3-dark.mp4#t=0.001)

## Retrieve channels in code

A script gets a channel from the Core before it reads or writes its data. Retrieve channels by name or key, by a pattern, or by a search term.

### By name or key

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

**Python**

```python
# One channel, by name or by key
tank_pressure = client.channels.retrieve("tank_pressure")
tank_pressure = client.channels.retrieve(tank_pressure.key)

# Many channels, by names or by keys
channels = client.channels.retrieve(["tank_pressure", "tank_temperature"])
channels = client.channels.retrieve([tank_pressure.key, tank_temperature.key])
```

When you pass one name or key, `retrieve` returns one channel. It raises `sy.NotFoundError` when no channel matches. When you pass a list, `retrieve` returns a list and leaves out the channels that it does not find.

Pass names or keys, not both in one list. A key never changes, but a name can change. Store keys in programs that run for a long time.

**TypeScript**

```typescript
// One channel, by name or by key
const tankPressure = await client.channels.retrieve("tank_pressure");
const sameChannel = await client.channels.retrieve(tankPressure.key);

// Many channels, by names or by keys
const names = ["tank_pressure", "tank_temperature"];
const byName = await client.channels.retrieve(names);
const byKey = await client.channels.retrieve([tankPressure.key, sameChannel.key]);
```

When you pass one name or key, `retrieve` returns one channel. It throws a `NotFoundError` when no channel matches. When you pass an array, `retrieve` returns an array and leaves out the channels that it does not find.

Pass names or keys, not both in one array. A key never changes, but a name can change. Store keys in programs that run for a long time.

### By pattern

A `name` filter with a `regex` matches names with a regular expression, in [Go RE2 syntax](https://github.com/google/re2/wiki/Syntax). The expression can match any part of the name, so start it with `^` to match from the start. For example, `^tank_` matches `tank_pressure` and `tank_time`, but not `ox_tank_pressure`. A plain name, as in the section above, always matches exactly.

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

**Python**

```python
import synnax as sy

# Returns list[sy.Channel]
tank_channels = client.channels.retrieve(
    where=sy.channel.Where(name=sy.filter.String(regex="^tank_"))
)
```

**TypeScript**

```typescript
// Returns Channel[]
const tankChannels = await client.channels.retrieve({
  where: { name: { regex: "^tank_" } },
});
```

### By search term

Both clients can search channels by a part of their name and filter them by their properties.

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

**Python**

```python
import synnax as sy

matches = client.channels.retrieve(search_term="pressure", limit=10)
floats = client.channels.retrieve(data_types=[sy.DataType.FLOAT32], is_index=False)
```

The filters are `search_term`, `data_types`, `not_data_types`, `is_index`, `virtual`, `internal`, `node_key`, and `limit`. Results match all the filters. Use `range_key` to include aliases from a range and search those aliases too. Set `include_status=True` to attach each channel’s status; a channel with no status gets `None`.

To read past the first page, sort with `order` and pass the position of the last channel as `after`:

```python
order = sy.channel.Order(field="name")
page = client.channels.retrieve(order=order, limit=100)
last = page[-1]
after = sy.channel.Cursor(key=last.key, name=last.name)
next_page = client.channels.retrieve(order=order, after=after, limit=100)
```

**TypeScript**

```typescript
import { DataType } from "@synnaxlabs/client";

// The ten best matches for "pressure"
const matches = await client.channels.retrieve({
  searchTerm: "pressure",
  limit: 10,
});

// All float32 data channels
const floats = await client.channels.retrieve({
  where: { dataType: { eq: DataType.FLOAT32 }, isIndex: { eq: false } },
});
```

| Filter       | Returns channels that                    |
| ------------ | ---------------------------------------- |
| `searchTerm` | Have a name that is similar to the term. |
| `where`      | Match the filter.                        |
| `limit`      | Are in the first `limit` results.        |
| `order`      | Sort by this field.                      |
| `after`      | Come after this position in the order.   |

A `where` filter matches the properties of a channel: `key`, `name`, `dataType`, `isIndex`, `virtual`, `internal`, and `leaseholder`. Use `and`, `or`, and `not` to combine filters. Synnax returns only the channels that match all of the filters.

## Find the channels of a range

A range can give channels a different name, called an [alias](https://docs.synnaxlabs.com/reference/ranges/aliases). To find channels by alias, or to read their data in a range, see [read and write range data](https://docs.synnaxlabs.com/reference/ranges/data).
