---
title: "Public WebSocket"
method: GET
path: "/ws"
tags: ["WebSocket"]
---

# Public WebSocket

`GET /ws`

Upgrade to a WebSocket connection for real-time public market data.

Public WebSocket streams do not require authentication.

## Subscribe

```json
{"action":"subscribe","channel":"ticker","market":"BTCZAR"}
{"action":"subscribe","channel":"orderbook","market":"BTCZAR","limit":10}
{"action":"subscribe","channel":"trades","market":"BTCZAR"}
```

## Unsubscribe

```json
{"action":"unsubscribe","channel":"ticker","market":"BTCZAR"}
```

## Client message fields

| Field | Type | Description |
|---|---|---|
| `action` | string | `subscribe` or `unsubscribe`. |
| `channel` | string | `ticker`, `orderbook`, or `trades`. |
| `market` | string | Market symbol, for example `BTCZAR`. |
| `limit` | integer | Order book depth. Applies to `orderbook` only. Default `50`, maximum `200`. |

## Server frames

```json
{"channel":"subscribed","market":"BTCZAR","subscription":"ticker"}
{"channel":"ticker","market":"BTCZAR","data":{}}
{"channel":"orderbook","market":"BTCZAR","data":{}}
{"channel":"trades","market":"BTCZAR","data":[]}
{"channel":"error","message":"..."}
```

## Poll intervals

| Channel | Interval |
|---|---|
| `ticker` | 1 second |
| `orderbook` | 500 milliseconds |
| `trades` | 1 second |

Frames are only pushed when data changes. The server sends a WebSocket
ping every 45 seconds. Clients must respond with a pong within 60 seconds
or the connection is closed.

## Other responses

- `101` — Switching Protocols - WebSocket upgrade successful.
- `503` — Market data service unavailable.

---

[API](https://skmtc.dev/altcointrader/apis/altcointrader-api.md) · [All operations](https://skmtc.dev/altcointrader/apis/altcointrader-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/altcointrader/altcointrader-api/revisions/fcbbd5bcd699/schema)
