Vizium Connection

Description of how to connect with vizium

In order to connect with vizium we neeed:

  1. SSH tunnel through a VPN to secure the connection

  2. Websocket tunneling to localhost

  3. Connect to the websocket

  4. Send subscription message

  5. Listen to price changes

SSH Tunnel

To connect to the SSH tunnel you will need this variables:

VIZIUM_SSH_IP: 161.35.6.32
VIZIUM_SSH_PORT: 22
VIZIUM_SSH_USERNAME: bp_ryan
VIZIUM_SSH_PRIVATE_KEY_PATH: /vizium.key
VIZIUM_WEBSOCKET_IP: 127.0.0.1
VIZIUM_WEBSOCKET_PORT: 4321

The private key is to be provided separately. Make sure to bind the websocket ip/port to a local ip/port. Check that you're connected to the vpn

Connect to the websocket

Stablish a websocket connection and send the subscription message:

symbols = {
    "btc": "0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c",
    "eth": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419",
    "matic": "0x7bAC85A8a13A4BcD8abb3eB7d6b4d632c5a57676",
    "link": "0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c",
}

subscribe_to = [
    {
        "type": "sub",
        "clSubId": index,
        "data": {
            "sType": "event",
            "addr": contract,
            "eName": "AnswerUpdated",
        },
    }
    for index, contract in enumerate(symbols.values())
]

Listen to the messages

After sending the message you will receive:

  1. An acknoledgement message: {"type":"init","cid":0}

  2. A confirmation for each subscription:

    {
       "type":"subconfirm",
       "subId":"31fa394f-a00a-11ee-ac3d-a65917587bba",
       "clSubId":0,
       "subType":"Event",
       "data":[
          "0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c",
          "AnswerUpdated"
       ]
    }
  3. An initial price update:

    {   
       "type":"subinitstate",
       "subId":"31faae04-a00a-11ee-af48-a65917587bba",
       "data":{
          "nwk":"eth",
          "ts":"2023-12-18 14:33:11+00:00",
          "bn":18813490,
          "eTxData":[
             {
                "current":"2165.65050000",
                "updatedAt":"2023-12-18 14:33:11",
                "mkt":"ETH/USD"
             }
          ]
       }
    }
  4. Future messages similar to the previous one with the price update.

Last updated