Compendium Trading Tools Documentation
CompendiumPENDAXCompendexOfficial Links
  • ⭐Platform Overview
  • ⚫PENDAX
    • 🌐What is PENDAX?
    • 🖱️PENDAX Capabilities
    • 💾Installing PENDAX modules
    • 💡Using PENDAX SDK
      • 💻Common Functions
      • 💻OKX Functions
        • Trading & Orders
        • Funding
        • Convert
        • Account & Subaccount
        • Grid Trading
        • Market Data
        • Public Data
        • Trading Data
      • 💻Bitget Functions
        • Public (Spot)
        • Market (Spot)
        • Wallet (Spot)
        • Account (Spot)
        • Trade (Spot)
        • Market (Futures)
        • Account (Futures)
        • Trade (Futures)
        • CopyTrade (Futures)
        • Sub Account Interface (Broker)
        • Sub API Interface (Broker)
      • 💻ByBit Functions
        • Market
        • Trading
        • Position
        • Account
        • Asset
        • User
        • Spot Leverage Token
        • Spot Margin Trade (UTA)
        • Spot Margin Trade (Normal)
        • Institutional Lending
      • 💻Mexc Functions
        • Market
        • Sub-Account
        • Spot Account/Trade
        • Wallet
        • ETF
        • Rebate
        • Futures Market
        • Futures Account and Trading
      • 💻Phemex Functions
        • Contract
        • Hedged Contract
        • Spot
        • Margin Trading
        • Transfer
        • Convert
        • Deposit And Withdraw
      • 💻BloFin Functions
        • Websocket
        • Account
        • Affiliate
        • Public Data
        • Trading
        • User
      • 💻BingX Functions
        • Fund Account
        • Wallet Deposits and Withdrawals
        • Sub-Account Managenent
        • Market Data (USDT-M)
        • Account (USDT-M)
        • Trades (USDT-M)
        • Market Data (Coin-M)
        • Trades (Coin-M)
        • Market Data (Spot)
        • Fund Account (Spot)
        • Trades (Spot)
        • CopyTrader
      • ⚠️FTX Functions
    • 📜License Agreement
  • 🟣Compendium App
    • 📈Compendium Trading Tools
    • 🔗Connect An Exchange Account
      • 🗝️OKX.com API Keys
    • 🤖Verified Trading Bots
      • Explore The Marketplace
      • For Algo & Strategy Authors
        • Get Listed & Verified
        • Strategy Monetization
        • Sending Trading Signals
        • Simplified Signal Program
      • For Users & Subscribers
        • Subscribing To Bots
        • Managing A Subscription
    • 💫Copy Trading Groups
      • For Copy Group Leaders
        • Creating A Copy Group
        • Linking Leader Account
        • Important Trading Notes
        • Manage A Copy Group
        • Discord Webhooks Setup
      • For Users & Subscribers
        • Subscribe To Copy Group
        • Link Account To Group
    • 📶Signal Provider Groups
      • For Group Leaders
        • Creating A Signal Group
        • Managing A Signal Group
        • Sending Trading Signals
      • For Users & Subscribers
        • Subscribing To Signal Groups
        • Manage Signal Group Subscription
  • 🔵Compendex Suite
    • 🔮DeFi With Compendex
    • ☀️Solana Integrations
      • Supported Solana Wallets
      • Overview And News
      • Openbook Spot Markets
      • Smart Swap Aggregator
      • NFT Metaverse Markets
      • Solana DeFi Analytics Portal
      • Community Tools List
  • 🪙The CMFI Token Ecosystem
    • 📊Tokenomics Breakdown
    • 🍎Trade Incentive Program
    • 🌊Staking And Liquidity Pools
      • ✨Raydium Liquidity Pools
      • 🐳Orca Liquidity Whirlpools
      • 🐋Orca Liquidity Pools
    • 🐷Compendi-Pigs NFT
  • 👥Community Info
    • ✅Links And Social Pages
    • 🎨Branding Guidelines
Powered by GitBook
On this page
  • BlofinSocket Object
  • Login
  • Subscribe
  • Unsubscribe
  1. PENDAX
  2. Using PENDAX SDK
  3. BloFin Functions

Websocket

BlofinSocket Object

Constructor:

 let myBlofinSocket = new BlofinSocket(options);

Usage:

import { BlofinSocket } from "./dev-package/sockets/blofinsocket.js";

  let onOpen = (options) => {
  	console.log("Hello World");
  }

  const exampleOpts = new BlofinSocket({
    key: "myKey",
    secret: "mySecret",
    passphrase: "myPassphrase",
    isPrivate: "true",
    clientOnOpen: onOpen
  });

  let myBlofinSocket = new BlofinSocket(exampleOpts);

Options:

  • apiKey: String

    • Given on creation of API key. Required

  • secret: String

    • Secret Key. Required if using private channels

  • passphrase: String

    • Passphrased created by user. Required if using private channels

  • isPrivate: Boolean

    • Indicates whether to use private channels. False by default

  • clientOnOpen: Function(options)

    • Function that takes the options given in the constructor as a parameter and should execute on creation of the websocket once finished opening

  • clientOnMessage: Function(options, msg)

    • Function that takes the options given in the constructor and an incoming message as parameters and should execute on reception of said message

  • clientOnError: Function(options, msg)

    • Function that takes the options given in the constructor and an incoming error as parameters and should execute on reception of said error

  • clientOnClose: Function(code, msg, options)

    • Function that takes a closing code, a message, and the options given in the constructor as parameters and should execute on close

Login

Please refer to the official BloFin API Docs for additional info.

Function name:

login()

Usage:

let onOpen = (options) => {
  options.socket.login();
}

  let myBlofinSocket = new BlofinSocket({
    key: "myKey",
    secret: "mySecret",
    passphrase: "myPassphrase",
    isPrivate: true,
    clientOnOpen: onOpen
  });

Subscribe

Please refer to the official BloFin API Docs for additional info.

Function name:

subscribe(subscriptions)

Usage:

let onOpen = (options) => {
  options.socket.login();
}


let onMessage = (options, msg) => {
  if (msg.event == 'login'){
    options.socket.subscribe({
                    args:
                        [{ channel: 'account'}]
                });
  }
}

  let myBlofinSocket = new BlofinSocket({
    key: "myKey",
    secret: "mySecret",
    passphrase: "myPassphrase",
    isPrivate: true,
    clientOnOpen: onOpen,
    clientOnMessage: onMessage
  });

Unsubscribe

Please refer to the official BloFin API Docs for additional info.

Function name:

unsubscribe(subscriptions)

Usage:

let onOpen = (options) => {
  options.socket.subscribe({

    args:
        [{ 
          channel: 'tickers',
          instId: 'BTC-USDT'
        }]
  });
  }
  
  
  let onMessage = (options, msg) => {
    
    if(msg.event == 'subscribe'){ 
        options.socket.unsubscribe([{ 
          channel: 'tickers',
          instId: 'BTC-USDT'
        }])
    

  }
  

  let myBlofinSocket = new BlofinSocket({
    key: "myKey",
    secret: "mySecret",
    passphrase: "myPassphrase",
    isPrivate: false,
    clientOnOpen: onOpen,
    clientOnMessage: onMessage
  });


PreviousBloFin FunctionsNextAccount

Last updated 1 year ago

⚫
💡
💻
https://docs.blofin.com/index.html#login
https://docs.blofin.com/index.html#subscribe
https://docs.blofin.com/index.html#unsubscribe