b2b.daowallet
Search…
Rates
Example using javascript
1
const ws = require('ws')
2
3
// Connect to server
4
const socket = new ws('wss://b2b.test.daowallet.com/migom/socket/');
5
6
// Add listener for open event
7
socket.addEventListener('open', function() {
8
console.log('Connected');
9
10
// Send message for subscribing rates by currencies EUR/USDT and USDT/EUR
11
// rate message have type: ["price","{\"pair\":\"EUR/USDT\",\"price\":1.10213079}"]
12
socket.send('42["subscribe",["EUR/USDT","USDT/EUR"]]');
13
socket.send('42["unsubscribe",["USDT/EUR"]]');
14
15
16
// Add ping for support aliving
17
setInterval(() => {
18
socket.send('42["ping"]')
19
}, 60 * 1000);
20
});
21
22
// add log for all messages
23
socket.addEventListener('message', function(message) {
24
console.log(message.data);
25
});
26
Copied!
Last modified 11mo ago
Copy link