Websocket

Description

Updates on system objects can be received through a WebSocket connection.

Connection URL

WebSocket URL: wss://my.kyrrex.mt.wldev.app (it’s malta stage url - pls use the necessary env url)

Authentication

To connect, you need to use api_key, api_secret (which can be obtained when generating a token in your account api_keys page), user_uuid (which can be obtained by requesting /api/v2/members/me as the uuid attribute), and api_sign - this is an HMAC signature created based on canonicalString. More details in the example.

Example Connection in JavaScript

Here is an example of connecting to the WebSocket server in JavaScript using the socket.io-client library:

const io = require('socket.io-client');
const crypto = require('crypto');

const SERVER_URL = 'wss://my.kyrrex.mt';

const api_key = 'kjdh723ncs73ncdsnc72ncs73kds32L3skD2';
const api_secret = 'GJSsaK3PpwOjgLK2lkPmQ5TZRtF2pPoQBZ9yyuAa';
const user_uuid = 'dfgkh45p8';

const canonicalString = `${user_uuid}|${api_key}`;

const ioClient = io.connect(SERVER_URL, {
  path: '/zsu/ws/v1',
  query: {
    api_key,
    api_sign: generateHmac(canonicalString, api_secret)
  },
  reconnection: true,
  reconnectionAttempts: Infinity,
  reconnectionDelay: 5000,
  reconnectionDelayMax: 10000,
  randomizationFactor: 0.5
});

function generateHmac(canonicalString, secret) {
  const hmac = crypto.createHmac('sha256', secret);
  return hmac.update(canonicalString).digest('hex');
}

ioClient.on('connect', () => {
  console.log('connected to:', SERVER_URL);
  console.log('with this api_key:', api_key);
});

ioClient.on('disconnect', (reason) => {
  console.log('Disconnected:', reason);
});

ioClient.on('close', (msg) => console.log('Connection closed:', msg));
ioClient.on('connect_error', (error) => console.log('Connection error:', error));

// Subscriptions for the selected objects, such as account, deposit_address, etc.

ioClient.on('account', (msg) => console.log('Message from server:', msg));
ioClient.on('deposit_address', (msg) => console.log('Message from server:', msg));

Possible Subscription Objects

  • customer

  • deposit

  • order

  • withdrawal

  • trade

  • deposit_address

  • account

Example Response

Example data for the account object received from the server:

{ "data": { "version": "1", "action": "update", "object": { "aml_locked": "0.0", "balance": "82.9858332031", "bonus": "10.0", "coin_type": "crypto", "currency": "usdt", "launchpad": "0.0", "locked": "14.12", "name": "usdt", "savings": "0.0", "stacking": "0.0", "tag": "", "total": "97.1058332031" } } }

This example demonstrates how a client can connect to the WebSocket server and process the messages received from it. Use the appropriate api_key, api_secret, and user_uuid for your connection.

Last updated