Back to Documentation
WebSocket API

Real-Time
WebSocket Streaming

Persistent connections for live market ticks, instant price updates, and real-time subscription management.

Endpoint
ws://127.0.0.1:8080
Auth
API Key
Auth Window
30 seconds

Connection Flow

Four steps from connection to live data.

1

Connect

Open a WebSocket connection to the server endpoint

2

Authenticate

Send your API key within the 30-second auth window

3

Subscribe

Subscribe to one or many symbols for live ticks

4

Stream

Receive real-time bid/ask ticks as JSON messages

You must authenticate within 30 seconds of connecting or the server will close the connection.

Message Reference

All JSON messages you send and receive over the WebSocket.

Client → Server

Authenticate

Required — send within 30 seconds of connecting

Required
{ "type": "auth", "apiKey": "<your-api-key>" }

Subscribe to Symbol

Start receiving ticks for a single instrument

{ "type": "subscribe", "symbol": "EURUSD" }

Subscribe to Multiple

Batch subscribe to many symbols at once

{ "type": "subscribe", "symbols": ["EURUSD", "GBPUSD", "XAUUSD"] }

Unsubscribe

Stop receiving ticks for a symbol

{ "type": "unsubscribe", "symbol": "EURUSD" }

List Subscriptions

Query your current active subscriptions

{ "type": "list" }

Server → Client

Tick Data

Real-time price update for a subscribed symbol

{
  "type": "tick",
  "symbol": "EURUSD",
  "bid": 1.0850,
  "ask": 1.0852,
  "time": 1709742000000
}

Auth Response

Confirms successful authentication

{
  "type": "auth",
  "success": true,
  "message": "Authenticated successfully"
}

Subscription Confirmation

Confirms subscription changes

{
  "type": "subscribed",
  "symbols": ["EURUSD"],
  "totalSubscriptions": 1
}

Error

Returned when a message is invalid or auth fails

{
  "type": "error",
  "message": "Authentication required"
}
Code Examples

Stream ticks
in any language

Full working examples covering connection, authentication, subscribing to symbols, and processing live tick data.

Connect and authenticate
Subscribe to multiple symbols
Process real-time tick messages
Handle reconnection gracefully

Tip: For Python, install websocket-client via pip. For Node.js, use the built-in ws package.

1import websocket, json
2
3API_KEY = "tk_live_a1b2c3d4e5f6"
4WS_URL = "ws://127.0.0.1:8080"
5
6ws = websocket.create_connection(WS_URL)
7print(ws.recv()) # Welcome message
8
9# Authenticate
10ws.send(json.dumps({"type": "auth", "apiKey": API_KEY}))
11auth = json.loads(ws.recv())
12print(f"Auth: {auth['message']}")
13
14# Subscribe to symbols
15ws.send(json.dumps({
16 "type": "subscribe",
17 "symbols": ["EURUSD", "GBPUSD", "XAUUSD"]
18}))
19print(ws.recv()) # Subscription confirmation
20
21# Stream ticks
22while True:
23 msg = json.loads(ws.recv())
24 if msg["type"] == "tick":
25 print(f"{msg['symbol']:>8} {msg['bid']:.5f} / {msg['ask']:.5f}")

Built for Real-Time

Enterprise-grade WebSocket infrastructure for production trading systems.

Sub-Millisecond Delivery

Ticks delivered from the matching engine to your client with minimal network overhead.

Multi-Symbol Streaming

Subscribe to hundreds of instruments on a single persistent connection.

API Key Authentication

Secure connections with scoped API keys and automatic timeout on unauthenticated sessions.

Auto-Reconnect Friendly

Stateless subscriptions — simply re-subscribe after reconnecting. No session state to restore.

Heartbeat & Keep-Alive

Built-in ping/pong to detect stale connections and keep firewalls from closing idle sockets.

Cross-Platform

Standard WebSocket protocol works with every language and platform — Python, Node.js, C#, browser JS, and more.

Need request-response instead?

Use our REST API for account management, trade execution, and market data queries.