---
title: WebSocket API Overview
description: Real-time streaming market data via persistent WebSocket connections.
---

# WebSocket API Overview

The WebSocket API delivers real-time market data over persistent WebSocket connections. Orderbook channels are served from `book` endpoints, while every other live feed uses `nonbook` endpoints.

## When to use WebSocket vs REST

|  | REST API | WebSocket API |
| --- | --- | --- |
| **Best for** | Historical queries, one-off lookups | Real-time dashboards, trading bots, live feeds |
| **Data delivery** | Request-response | Server pushes updates as they occur |
| **Connection** | New HTTP request per query | JSON WebSocket connection(s) by endpoint family |
| **Latency** | Higher (per-request overhead) | Lower (no connection overhead per message) |

## Available channels

| Channel | Description | Key parameters |
| --- | --- | --- |
| `TRADE` | Individual trades | -- |
| `TRADE_AGG` | Aggregated trades (OHLCV batches) | `batchInterval` |
| `BLOCK_BOOK_SNAPSHOT` | Orderbook depth snapshots | `blockSize`, `maxDepth`, `updateFrequency` |
| `LIQUIDATION` | Individual liquidation events | -- |
| `FUNDING_RATE` | Funding rate updates | -- |
| `OPEN_INTEREST` | Open interest updates | -- |
| `VOLUME_PROFILE_AGG` | Real-time volume profile | `groupByType` |

## Endpoint selection

Choose the endpoint family that matches the channels you want:

| Endpoint family | Channels | Singapore | Europe |
| --- | --- | --- | --- |
| `book` | `BLOCK_BOOK_SNAPSHOT` | `wss://ap-sin3.ws.api.kiyotaka.ai/ws` | `wss://eu-de3.ws.api.kiyotaka.ai/ws` |
| `nonbook` | `TRADE`, `TRADE_AGG`, `LIQUIDATION`, `FUNDING_RATE`, `OPEN_INTEREST`, `VOLUME_PROFILE_AGG` | `wss://ap-sin3.ws.api.kiyotaka.ai/nonbook/ws` | `wss://eu-de3.ws.api.kiyotaka.ai/nonbook/ws` |

Pick the region closest to your deployment. Add `?encoding=json` to the endpoint you use. If you consume both orderbook and non-orderbook data, keep one connection to each endpoint family.

## Quick example

Connect, authenticate, subscribe, and receive non-orderbook data:

<CodeBlock lang="Connect">
<pre><span class="s-s">wss://ap-sin3.ws.api.kiyotaka.ai/nonbook/ws?encoding=json</span></pre>
</CodeBlock>

<CodeBlock lang="Authenticate">
<pre>{
  <span class="s-p">"method"</span>: <span class="s-s">"public/authenticate"</span>,
  <span class="s-p">"params"</span>: {
    <span class="s-p">"token"</span>: <span class="s-s">"YOUR_API_KEY"</span>
  }
}</pre>
</CodeBlock>

<CodeBlock lang="Subscribe">
<pre>{
  <span class="s-p">"jsonrpc"</span>: <span class="s-s">"2.0"</span>,
  <span class="s-p">"id"</span>: <span class="s-n">0</span>,
  <span class="s-p">"method"</span>: <span class="s-s">"public/subscribe"</span>,
  <span class="s-p">"params"</span>: {
    <span class="s-p">"channels"</span>: [
      {
        <span class="s-p">"type"</span>: <span class="s-s">"TRADE"</span>,
        <span class="s-p">"exchange"</span>: <span class="s-s">"BINANCE_FUTURES"</span>,
        <span class="s-p">"symbol"</span>: <span class="s-s">"BTCUSDT"</span>,
        <span class="s-p">"category"</span>: <span class="s-s">"*"</span>
      }
    ],
    <span class="s-p">"compression"</span>: <span class="s-s">"brotli"</span>,
    <span class="s-p">"version"</span>: <span class="s-s">"v2"</span>
  }
}</pre>
</CodeBlock>

<CodeBlock lang="Receive">
<pre>{
  <span class="s-p">"points"</span>: [
    {
      <span class="s-p">"series"</span>: {
        <span class="s-p">"type"</span>: <span class="s-s">"TRADE"</span>,
        <span class="s-p">"symbol"</span>: <span class="s-s">"BTCUSDT"</span>,
        <span class="s-p">"exchange"</span>: <span class="s-s">"BINANCE_FUTURES"</span>,
        <span class="s-p">"normalizedSymbol"</span>: <span class="s-s">"BTC-USDT"</span>,
        <span class="s-p">"category"</span>: <span class="s-s">"PERPETUAL"</span>,
        <span class="s-p">"side"</span>: <span class="s-s">"BUY"</span>,
        <span class="s-p">"coin"</span>: <span class="s-s">"BTC"</span>
      },
      <span class="s-p">"trade"</span>: {
        <span class="s-p">"id"</span>: <span class="s-s">"7126482260"</span>,
        <span class="s-p">"price"</span>: <span class="s-n">90003</span>,
        <span class="s-p">"amount"</span>: <span class="s-n">0.002</span>,
        <span class="s-p">"timestamp"</span>: {
          <span class="s-p">"seconds"</span>: <span class="s-n">1769058875</span>,
          <span class="s-p">"nanoseconds"</span>: <span class="s-n">830000000</span>
        }
      }
    }
  ]
}</pre>
</CodeBlock>