# 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).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.koinju.io/connect-your-tools/clickhouse-cli-and-bi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
