订阅大K线24H数据的websocket接口
<p>[TOC]</p>
<h5>简要描述</h5>
<ul>
<li>订阅大K线24H数据的websocket接口</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>http://doge-test-api.2travel.vip/market/swap-ws/websocket</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>websocket </li>
</ul>
<h5>参数</h5>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">必选</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">/topic/market/price/24h/{symbol}</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>订阅24H数据(symbol:BTC/USDT),币种需大写</td>
</tr>
</tbody>
</table>
<h5>返回示例</h5>
<pre><code> Received: {&quot;high24h&quot;:67842,&quot;low24h&quot;:66645.9,&quot;volCcy24h&quot;:95591.929,&quot;volCcy24hUSDT&quot;:6417086193.77}</code></pre>
<h5>返回参数说明</h5>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">high24h</td>
<td style="text-align: left;">String</td>
<td>24小时最高价</td>
</tr>
<tr>
<td style="text-align: left;">low24h</td>
<td style="text-align: left;">String</td>
<td>24小时最低价</td>
</tr>
<tr>
<td style="text-align: left;">volCcy24h</td>
<td style="text-align: left;">String</td>
<td>24小时成交量-CoinSymbol-BTC</td>
</tr>
<tr>
<td style="text-align: left;">volCcy24hUSDT</td>
<td style="text-align: left;">String</td>
<td>24小时成交量-BaseSymbol-USDT</td>
</tr>
</tbody>
</table>
<h5>备注</h5>
<p>web端订阅方式:</p>
<p><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>WebSocket Example</title>
<script src="<a href="https://cdn.jsdelivr.net/npm/sockjs-client/dist/sockjs.min.js"></script>">https://cdn.jsdelivr.net/npm/sockjs-client/dist/sockjs.min.js"></script></a>;
<script src="<a href="https://cdn.jsdelivr.net/npm/stompjs/lib/stomp.min.js"></script>">https://cdn.jsdelivr.net/npm/stompjs/lib/stomp.min.js"></script></a>;
</head>
<body>
<h1>WebSocket STOMP Example</h1>
<div id="messages"></div></p>
<pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
var socket = new SockJS(&#039;http://doge-test-api.dogeworld.store/market/swap-ws&#039;);
var stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
console.log(&#039;Connected: &#039; + frame);
// ���� &#039;/user/queue/notifications&#039; Ŀ�ĵص���Ϣ
stompClient.subscribe(&#039;/topic/market/price/24h/BTC/USDT&#039;, function (notification) {
var message = JSON.parse(notification.body);
// ��ҳ��������յ�����Ϣ
var messagesElement = document.getElementById(&#039;messages&#039;);
messagesElement.innerHTML += &#039;&lt;p&gt;Received: &#039; + JSON.stringify(message) + &#039;&lt;/p&gt;&#039;;
});
});
// �������ӶϿ����ӵĹ���
function disconnect() {
if (stompClient !== null) {
stompClient.disconnect();
}
console.log(&quot;Disconnected&quot;);
}
// ȷ����ҳ��ж��ʱ�Ͽ�����
window.onbeforeunload = disconnect;
&lt;/script&gt;</code></pre>
<p></body>
</html></p>