Connect and subscribe to realtime market data.
const ws = new WebSocket('wss://api.tickdb.ai/v1/realtime?api_key=YOUR_API_KEY'); ws.onopen = () => { console.log('connected'); ws.send(JSON.stringify({ cmd: 'subscribe', data: { channel: 'ticker', symbols: ['BTCUSDT'] } })); }; ws.onmessage = (evt) => { const msg = JSON.parse(evt.data); console.log('message', msg); }; ws.onclose = () => console.log('closed'); ws.onerror = (e) => console.error('error', e);
ws.send(JSON.stringify({ cmd: 'subscribe', data: { channel: 'ticker', symbols: ['AAPL.US', '700.HK', 'BTCUSDT'] } })); ws.send(JSON.stringify({ cmd: 'subscribe', data: { channel: 'depth', symbols: ['AAPL.US', '700.HK', 'BTCUSDT'] } })); ws.send(JSON.stringify({ cmd: 'subscribe', data: { channel: 'trade', symbols: ['AAPL.US', '700.HK', 'BTCUSDT'] } }));