> For the complete documentation index, see [llms.txt](https://docs.tanx.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tanx.fi/tech/api-documentation/web-socket-stream/public-websocket-connection.md).

# Public websocket connection

Make use of this public web-socket connection in order to get real-time trades, orderbook and K-line data. Please note that this is a <mark style="background-color:purple;">Private 🔒</mark> route which means it needs to be authorised by the account initiating this request.

### URL <a href="#url" id="url"></a>

```url
wss://api.tanx.fi/public
```

### Subscribe <a href="#subscribe" id="subscribe"></a>

```json
{
  "event": "subscribe",
  "streams": ["btcusdc.trades", "btcusdc.ob-inc", "btcusdc.kline-5m"]
}
```

### Unsubscribe <a href="#unsubscribe" id="unsubscribe"></a>

```json
{
  "event": "unsubscribe",
  "streams": ["btcusdc.trades", "btcusdc.ob-inc", "btcusdc.kline-5m"]
}
```

### Available Streams <a href="#available-streams" id="available-streams"></a>

#### 1. Trade streams - `<symbol>.trades` <a href="#id-1-trade-streams---symboltrades" id="id-1-trade-streams---symboltrades"></a>

#### Response

```json
{
  "btcusdc.trades": {
    "trades": [
      {
        "amount": "0.001",
        "date": 1659023778,
        "price": "23935.01",
        "taker_type": "buy",
        "tid": 448639
      }
    ]
  }
}

  
 
```

#### 2. Orderbook streams - `<symbol>.ob-inc` <a href="#id-2-orderbook-streams---symbolob-inc" id="id-2-orderbook-streams---symbolob-inc"></a>

#### Response for ask

```json
{
  "btcusdc.ob-inc": {
    "asks": ["23707.65", "0.034"],
    "sequence": 393494
  }
} 
```

#### Response for bid

```json
{
  "btcusdc.ob-inc": {
    "bids": ["23728.62", ""],
    "sequence": 393575
  }
}
```

#### 3. Kline/Candlestick streams - `<symbol>.kline-<period>` <a href="#id-3-klinecandlestick-streams---symbolkline-period" id="id-3-klinecandlestick-streams---symbolkline-period"></a>

> Period options - 1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 3d, 1w

#### Response

```json
{
  "btcusdc.kline-5m": [1659024300, 23935.01, 23935.01, 23935.01, 23935.01, 0]
}
```

> Note : Kline payload item as array of numbers
>
> Example: \[1660634520, 0.0839, 0.0921, 0.0781, 0.0845, 0.5895]
>
> 1. Timestamp.
> 2. Open price.
> 3. Max price.
> 4. Min price.
> 5. Last price.
> 6. Period volume


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.tanx.fi/tech/api-documentation/web-socket-stream/public-websocket-connection.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
