---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ytsaurus.tech/docs/en/user-guide/data-processing/chyt/cli-and-api.md
  - https://ytsaurus.tech/docs/ru/user-guide/data-processing/chyt/cli-and-api.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ytsaurus.tech/docs/en/llms.txt

<!-- source: en/_includes/user-guide/data-processing/chyt/cli-and-api-intro.md -->
# CLI and Python API

You can use the CHYT CLI and the CHYT Python API to run your clique or send a query to CHYT from a program or the command line. They can be obtained as part of the `ytsaurus-client`.

The command line utility accepts two environment variables: `YT_PROXY` and `CHYT_ALIAS`. You can use the former to specify the YTsaurus cluster, and the latter to specify the used clique.

For example, you can use the following command for Linux and macOS to set environment variables and no longer pass the `--proxy <cluster_name>` and `--alias ch_public` parameters to all subsequent calls:

```bash
export YT_PROXY=<cluster_name> CHYT_ALIAS=ch_public
```
{% note info "Note" %}

To ensure compatibility with older versions, a clique alias can be specified with an asterisk at the beginning. In this case, it is ignored.

{% endnote %}

The process that launches the clique can sometimes be informally called a *launcher*.

## ytsaurus-client { #ytsaurus-client }

The main way to get started with YTsaurus is to install the `ytsaurus-client` package. For more information, see [Python Wrapper](https://ytsaurus.tech/docs/en/api/python/start.md).
<!-- endsource: en/_includes/user-guide/data-processing/chyt/cli-and-api-intro.md -->

<!-- source: en/_includes/user-guide/data-processing/chyt/cli-and-api-details.md -->
The package includes `yt`. In order to use the CHYT features, you can run any command as `yt clickhouse [command]`.

For example, you can make a test query to the public clique `ch_public` as follows:

```bash
yt clickhouse execute "select 'Hello world'" --alias ch_public
```

The package additionally contains the CHYT Python API available in the `yt.clickhouse` module:

```bash
python3
Python 3.7.3 (default, Oct  7 2019, 12:56:13)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yt.clickhouse as chyt
>>> import yt.wrapper as yt
>>> client = yt.YtClient("<cluster_name>")
>>> list(chyt.execute("select * from `//home/user/sample_table`", alias="ch_public", client=client))
[{'a': 100}, {'a': 101}, {'a': 102}, {'a': 205}, {'a': 206}, {'a': 1100}]
```

The library is available for Python 3.

For more detailed specification of the Python API and CLI features, see [Executing queries](https://ytsaurus.tech/docs/en/user-guide/data-processing/chyt/reference/execute.md).
<!-- endsource: en/_includes/user-guide/data-processing/chyt/cli-and-api-details.md -->
