Rates

Example using javascript
​
const ws = require('ws')
​
// Connect to server
const socket = new ws('wss://my.cryptopayments.pro/migom/socket/');
​
// Add listener for open event
socket.addEventListener('open', function() {
console.log('Connected');
​
// Send message for subscribing rates by currencies EUR/USDT and USDT/EUR
// rate message have type: ["price","{\"pair\":\"EUR/USDT\",\"price\":1.10213079}"]
socket.send('42["subscribe",["EUR/USDT","USDT/EUR"]]');
socket.send('42["unsubscribe",["USDT/EUR"]]');
​
​
// Add ping for support aliving
setInterval(() => {
socket.send('42["ping"]')
}, 60 * 1000);
});
​
// add log for all messages
socket.addEventListener('message', function(message) {
console.log(message.data);
});
​
​
Last modified 1yr ago