BITMEX
Bitmex API javascript socket subscribe
The following subscription topics are available without authentication:
The following subjects require authentication:
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/hmac-sha256.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/components/enc-base64-min.js"></script>
<script type="text/javascript">
function getSocket(API_KEY,API_SECRET){
var timestamp = new Date().getTime();
var message = "GET/realtime"+timestamp;
var bitmex_signature = CryptoJS.HmacSHA256(message, API_SECRET);
var exampleSocket = new WebSocket("wss://www.bitmex.com/realtime?");
exampleSocket.onopen = function (){
exampleSocket.send("{\"op\" : \"authKeyExpires\", \"args\" : [\""+API_KEY+"\","+timestamp+",\""+bitmex_signature+"\"]}");
exampleSocket.send("{\"op\" : \"subscribe\" , \"args\" : [\"position\",\"wallet\",\"margin\",\"order\"]}");
}
exampleSocket.onmessage = function (event) {
console.log(event.data);
}
}
</script>
댓글 쓰기
0 댓글