订阅大K线深度图的websocket接口
<p>[TOC]</p>
<h5>简要描述</h5>
<ul>
<li>订阅大K线深度图的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/depth/{symbol}</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>订阅深度图(symbol:BTC/USDT),币种需大写</td>
</tr>
</tbody>
</table>
<h5>返回示例</h5>
<pre><code>Received: {&quot;asks&quot;:[[&quot;1077&quot;,&quot;5.496&quot;],[&quot;15047&quot;,&quot;5.497&quot;],[&quot;45488&quot;,&quot;5.498&quot;],[&quot;20613&quot;,&quot;5.499&quot;],[&quot;30181&quot;,&quot;5.5&quot;],[&quot;61874&quot;,&quot;5.501&quot;],[&quot;38714&quot;,&quot;5.502&quot;],[&quot;27617&quot;,&quot;5.503&quot;],[&quot;38421&quot;,&quot;5.504&quot;],[&quot;64705&quot;,&quot;5.505&quot;],[&quot;24292&quot;,&quot;5.506&quot;],[&quot;38556&quot;,&quot;5.507&quot;],[&quot;49848&quot;,&quot;5.508&quot;],[&quot;163947&quot;,&quot;5.509&quot;],[&quot;58662&quot;,&quot;5.51&quot;],[&quot;21098&quot;,&quot;5.511&quot;],[&quot;6252&quot;,&quot;5.512&quot;],[&quot;6407&quot;,&quot;5.513&quot;],[&quot;36379&quot;,&quot;5.514&quot;],[&quot;9771&quot;,&quot;5.515&quot;],[&quot;5633&quot;,&quot;5.516&quot;],[&quot;7298&quot;,&quot;5.517&quot;],[&quot;212514&quot;,&quot;5.518&quot;],[&quot;7188&quot;,&quot;5.519&quot;],[&quot;13445&quot;,&quot;5.52&quot;],[&quot;7425&quot;,&quot;5.521&quot;],[&quot;7420&quot;,&quot;5.522&quot;],[&quot;7582&quot;,&quot;5.523&quot;],[&quot;9676&quot;,&quot;5.524&quot;],[&quot;15299&quot;,&quot;5.525&quot;],[&quot;2781&quot;,&quot;5.526&quot;],[&quot;4882&quot;,&quot;5.527&quot;],[&quot;6436&quot;,&quot;5.528&quot;],[&quot;6341&quot;,&quot;5.529&quot;],[&quot;4807&quot;,&quot;5.53&quot;],[&quot;4650&quot;,&quot;5.531&quot;],[&quot;4143&quot;,&quot;5.532&quot;],[&quot;6307&quot;,&quot;5.533&quot;],[&quot;3986&quot;,&quot;5.534&quot;],[&quot;2503&quot;,&quot;5.535&quot;],[&quot;2806&quot;,&quot;5.536&quot;],[&quot;2432&quot;,&quot;5.537&quot;],[&quot;7621&quot;,&quot;5.538&quot;],[&quot;73&quot;,&quot;5.539&quot;],[&quot;2401&quot;,&quot;5.54&quot;],[&quot;31&quot;,&quot;5.541&quot;],[&quot;1369&quot;,&quot;5.542&quot;],[&quot;10200&quot;,&quot;5.543&quot;],[&quot;1958&quot;,&quot;5.544&quot;],[&quot;284402&quot;,&quot;5.545&quot;],[&quot;55&quot;,&quot;5.546&quot;],[&quot;1139&quot;,&quot;5.547&quot;],[&quot;8323&quot;,&quot;5.548&quot;],[&quot;2977&quot;,&quot;5.549&quot;],[&quot;8426&quot;,&quot;5.55&quot;],[&quot;1501&quot;,&quot;5.551&quot;],[&quot;1764&quot;,&quot;5.552&quot;],[&quot;193&quot;,&quot;5.553&quot;],[&quot;7450&quot;,&quot;5.554&quot;],[&quot;1415&quot;,&quot;5.555&quot;],[&quot;91&quot;,&quot;5.556&quot;],[&quot;4571&quot;,&quot;5.557&quot;],[&quot;35&quot;,&quot;5.558&quot;],[&quot;1370&quot;,&quot;5.559&quot;],[&quot;16283&quot;,&quot;5.56&quot;],[&quot;1468&quot;,&quot;5.561&quot;],[&quot;998&quot;,&quot;5.562&quot;],[&quot;8613&quot;,&quot;5.563&quot;],[&quot;43&quot;,&quot;5.564&quot;],[&quot;623&quot;,&quot;5.565&quot;],[&quot;1164&quot;,&quot;5.566&quot;],[&quot;5558&quot;,&quot;5.567&quot;],[&quot;12155&quot;,&quot;5.568&quot;],[&quot;248&quot;,&quot;5.569&quot;],[&quot;939&quot;,&quot;5.57&quot;],[&quot;2749&quot;,&quot;5.571&quot;],[&quot;3141&quot;,&quot;5.572&quot;],[&quot;1773&quot;,&quot;5.573&quot;],[&quot;2099&quot;,&quot;5.574&quot;],[&quot;3453&quot;,&quot;5.575&quot;],[&quot;3346&quot;,&quot;5.576&quot;],[&quot;2311&quot;,&quot;5.577&quot;],[&quot;427&quot;,&quot;5.578&quot;],[&quot;20077&quot;,&quot;5.579&quot;],[&quot;16537&quot;,&quot;5.58&quot;],[&quot;3719&quot;,&quot;5.581&quot;],[&quot;41&quot;,&quot;5.582&quot;],[&quot;759&quot;,&quot;5.583&quot;],[&quot;1871&quot;,&quot;5.584&quot;],[&quot;179&quot;,&quot;5.585&quot;],[&quot;3040&quot;,&quot;5.586&quot;],[&quot;8897&quot;,&quot;5.587&quot;],[&quot;182&quot;,&quot;5.588&quot;],[&quot;237&quot;,&quot;5.589&quot;],[&quot;1071&quot;,&quot;5.59&quot;],[&quot;299&quot;,&quot;5.591&quot;],[&quot;401&quot;,&quot;5.592&quot;],[&quot;370&quot;,&quot;5.593&quot;],[&quot;9&quot;,&quot;5.594&quot;],[&quot;2906&quot;,&quot;5.595&quot;]],&quot;bids&quot;:[[&quot;5.495&quot;,&quot;6205&quot;],[&quot;5.494&quot;,&quot;11662&quot;],[&quot;5.493&quot;,&quot;25531&quot;],[&quot;5.492&quot;,&quot;29435&quot;],[&quot;5.491&quot;,&quot;51450&quot;],[&quot;5.49&quot;,&quot;50195&quot;],[&quot;5.489&quot;,&quot;57633&quot;],[&quot;5.488&quot;,&quot;32643&quot;],[&quot;5.487&quot;,&quot;58203&quot;],[&quot;5.486&quot;,&quot;40356&quot;],[&quot;5.485&quot;,&quot;36707&quot;],[&quot;5.484&quot;,&quot;52392&quot;],[&quot;5.483&quot;,&quot;68814&quot;],[&quot;5.482&quot;,&quot;178881&quot;],[&quot;5.481&quot;,&quot;41645&quot;],[&quot;5.48&quot;,&quot;16115&quot;],[&quot;5.479&quot;,&quot;15248&quot;],[&quot;5.478&quot;,&quot;46247&quot;],[&quot;5.477&quot;,&quot;18225&quot;],[&quot;5.476&quot;,&quot;12195&quot;],[&quot;5.475&quot;,&quot;38693&quot;],[&quot;5.474&quot;,&quot;27684&quot;],[&quot;5.473&quot;,&quot;10795&quot;],[&quot;5.472&quot;,&quot;27368&quot;],[&quot;5.471&quot;,&quot;50507&quot;],[&quot;5.47&quot;,&quot;14067&quot;],[&quot;5.469&quot;,&quot;4030&quot;],[&quot;5.468&quot;,&quot;42923&quot;],[&quot;5.467&quot;,&quot;5926&quot;],[&quot;5.466&quot;,&quot;6019&quot;],[&quot;5.465&quot;,&quot;203238&quot;],[&quot;5.464&quot;,&quot;5501&quot;],[&quot;5.463&quot;,&quot;20629&quot;],[&quot;5.462&quot;,&quot;21656&quot;],[&quot;5.461&quot;,&quot;7110&quot;],[&quot;5.46&quot;,&quot;3060&quot;],[&quot;5.459&quot;,&quot;7607&quot;],[&quot;5.458&quot;,&quot;22503&quot;],[&quot;5.457&quot;,&quot;3912&quot;],[&quot;5.456&quot;,&quot;21461&quot;],[&quot;5.455&quot;,&quot;16735&quot;],[&quot;5.454&quot;,&quot;21301&quot;],[&quot;5.453&quot;,&quot;6215&quot;],[&quot;5.452&quot;,&quot;15364&quot;],[&quot;5.451&quot;,&quot;6140&quot;],[&quot;5.45&quot;,&quot;7451&quot;],[&quot;5.449&quot;,&quot;4522&quot;],[&quot;5.448&quot;,&quot;31511&quot;],[&quot;5.447&quot;,&quot;23161&quot;],[&quot;5.446&quot;,&quot;3655&quot;],[&quot;5.445&quot;,&quot;9912&quot;],[&quot;5.444&quot;,&quot;2618&quot;],[&quot;5.443&quot;,&quot;12027&quot;],[&quot;5.442&quot;,&quot;15184&quot;],[&quot;5.441&quot;,&quot;10509&quot;],[&quot;5.44&quot;,&quot;19561&quot;],[&quot;5.439&quot;,&quot;10879&quot;],[&quot;5.438&quot;,&quot;11450&quot;],[&quot;5.437&quot;,&quot;6336&quot;],[&quot;5.436&quot;,&quot;77640&quot;],[&quot;5.435&quot;,&quot;4890&quot;],[&quot;5.434&quot;,&quot;24579&quot;],[&quot;5.433&quot;,&quot;13129&quot;],[&quot;5.432&quot;,&quot;40&quot;],[&quot;5.431&quot;,&quot;12859&quot;],[&quot;5.43&quot;,&quot;20597&quot;],[&quot;5.429&quot;,&quot;14159&quot;],[&quot;5.428&quot;,&quot;19235&quot;],[&quot;5.427&quot;,&quot;2500&quot;],[&quot;5.426&quot;,&quot;87861&quot;],[&quot;5.425&quot;,&quot;372609&quot;],[&quot;5.424&quot;,&quot;3121&quot;],[&quot;5.423&quot;,&quot;211585&quot;],[&quot;5.422&quot;,&quot;6480&quot;],[&quot;5.421&quot;,&quot;9586&quot;],[&quot;5.42&quot;,&quot;28689&quot;],[&quot;5.419&quot;,&quot;21375&quot;],[&quot;5.418&quot;,&quot;5654&quot;],[&quot;5.417&quot;,&quot;4011&quot;],[&quot;5.416&quot;,&quot;7739&quot;],[&quot;5.415&quot;,&quot;140761&quot;],[&quot;5.414&quot;,&quot;1141&quot;],[&quot;5.413&quot;,&quot;6465&quot;],[&quot;5.412&quot;,&quot;42649&quot;],[&quot;5.411&quot;,&quot;1219&quot;],[&quot;5.41&quot;,&quot;13985&quot;],[&quot;5.409&quot;,&quot;7125&quot;],[&quot;5.408&quot;,&quot;33374&quot;],[&quot;5.407&quot;,&quot;168&quot;],[&quot;5.406&quot;,&quot;90654&quot;],[&quot;5.405&quot;,&quot;9179&quot;],[&quot;5.404&quot;,&quot;1817&quot;],[&quot;5.403&quot;,&quot;475&quot;],[&quot;5.402&quot;,&quot;1743&quot;],[&quot;5.401&quot;,&quot;9604&quot;],[&quot;5.4&quot;,&quot;107068&quot;],[&quot;5.399&quot;,&quot;286&quot;],[&quot;5.398&quot;,&quot;2324&quot;],[&quot;5.397&quot;,&quot;879&quot;],[&quot;5.396&quot;,&quot;727&quot;]]}</code></pre>
<pre><code>{
asks: [
[
&quot;93416.1&quot;,
&quot;850.2&quot;
],
[
&quot;93417.2&quot;,
&quot;0.1&quot;
],
[
&quot;93418.6&quot;,
&quot;0.1&quot;
],
[
&quot;93419&quot;,
&quot;19.3&quot;
],
bids: [
[
&quot;93416&quot;,
&quot;803&quot;
],
[
&quot;93415.5&quot;,
&quot;100&quot;
],
[
&quot;93413.9&quot;,
&quot;30&quot;
],
[
&quot;93412.4&quot;,
&quot;55.4&quot;
],...(后面还有96条)
]
}</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;">» asks</td>
<td style="text-align: left;">JSONArray</td>
<td>卖方深度</td>
</tr>
<tr>
<td style="text-align: left;">» bids</td>
<td style="text-align: left;">JSONArray</td>
<td>买方深度</td>
</tr>
<tr>
<td style="text-align: left;">» ts</td>
<td style="text-align: left;">String</td>
<td>null</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th style="text-align: left;">asks和bids内参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">» » 1位</td>
<td style="text-align: left;">String</td>
<td>深度价格</td>
</tr>
<tr>
<td style="text-align: left;">» » 2位</td>
<td style="text-align: left;">String</td>
<td>价格的数量</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/depth/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>