dogo

Dgcoin


订阅大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: {&amp;quot;high24h&amp;quot;:67842,&amp;quot;low24h&amp;quot;:66645.9,&amp;quot;volCcy24h&amp;quot;:95591.929,&amp;quot;volCcy24hUSDT&amp;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>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;title&gt;WebSocket Example&lt;/title&gt; &lt;script src=&quot;<a href="https://cdn.jsdelivr.net/npm/sockjs-client/dist/sockjs.min.js&quot;&gt;&lt;/script&gt">https://cdn.jsdelivr.net/npm/sockjs-client/dist/sockjs.min.js&quot;&gt;&lt;/script&gt</a>; &lt;script src=&quot;<a href="https://cdn.jsdelivr.net/npm/stompjs/lib/stomp.min.js&quot;&gt;&lt;/script&gt">https://cdn.jsdelivr.net/npm/stompjs/lib/stomp.min.js&quot;&gt;&lt;/script&gt</a>; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;WebSocket STOMP Example&lt;/h1&gt; &lt;div id=&quot;messages&quot;&gt;&lt;/div&gt;</p> <pre><code>&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt; var socket = new SockJS(&amp;#039;http://doge-test-api.dogeworld.store/market/swap-ws&amp;#039;); var stompClient = Stomp.over(socket); stompClient.connect({}, function (frame) { console.log(&amp;#039;Connected: &amp;#039; + frame); // ���� &amp;#039;/user/queue/notifications&amp;#039; Ŀ�ĵص���Ϣ stompClient.subscribe(&amp;#039;/topic/market/price/24h/BTC/USDT&amp;#039;, function (notification) { var message = JSON.parse(notification.body); // ��ҳ��������յ�����Ϣ var messagesElement = document.getElementById(&amp;#039;messages&amp;#039;); messagesElement.innerHTML += &amp;#039;&amp;lt;p&amp;gt;Received: &amp;#039; + JSON.stringify(message) + &amp;#039;&amp;lt;/p&amp;gt;&amp;#039;; }); }); // �������ӶϿ����ӵĹ��� function disconnect() { if (stompClient !== null) { stompClient.disconnect(); } console.log(&amp;quot;Disconnected&amp;quot;); } // ȷ����ҳ��ж��ʱ�Ͽ����� window.onbeforeunload = disconnect; &amp;lt;/script&amp;gt;</code></pre> <p>&lt;/body&gt; &lt;/html&gt;</p>

页面列表

ITEM_HTML