> For the complete documentation index, see [llms.txt](https://docs.koinju.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.koinju.io/connect-your-tools/clickhouse-cli-and-bi.md).

# ClickHouse CLI & BI tools

Connect from the `clickhouse-client` command line, plain `curl`, or any major BI tool.

## Before you start

| Setting       | Value                     |
| ------------- | ------------------------- |
| Host          | the provided database URL |
| Port          | 8443                      |
| Protocol      | HTTPS / SSL enabled       |
| Database      | api                       |
| User/Password | provided by Koinju        |

Don't have credentials yet? See [How to connect](/how-to-connect.md).

## Step-by-step

### Native CLI — `clickhouse-client`

The native client uses the TLS native protocol on port `9440`:

```sh
clickhouse-client \
  --host <host> \
  --port 9440 \
  --secure \
  --user <user> \
  --password \
  --database api
```

`--password` with no value prompts interactively. Once connected you get an interactive SQL shell.

### HTTP CLI — `curl`

The HTTPS interface on port `8443` accepts a query as the POST body with HTTP Basic auth:

```sh
curl --user <user>:<pass> \
  'https://<host>:8443/?database=api' \
  --data-binary "SELECT exchange, market, timestamp, price FROM api.trade WHERE market LIKE 'BTC%' AND timestamp > toStartOfDay(now()) ORDER BY timestamp DESC LIMIT 20"
```

### BI tools

Tableau, Metabase, Superset, Power BI and similar tools all connect to the **same HTTPS endpoint on port 8443** (host = the provided database URL, database = `api`, SSL enabled, user/password provided by Koinju). ClickHouse maintains official, tool-by-tool setup guides — follow them and plug in the connection facts above: [ClickHouse data-visualization integrations](https://clickhouse.com/docs/integrations/data-visualization).

## First sanity query

```sql
SELECT exchange, market, timestamp, price
FROM api.trade
WHERE market LIKE 'BTC%' AND timestamp > toStartOfDay(now())
ORDER BY timestamp DESC LIMIT 20
```

If you get \~20 rows back, you're connected. Next, explore what data is available in [Data](/data/coverage.md).
