HollaEx®
⚙️ DashboardStart →
  • HollaEx® — The Crypto Exchange Solution
  • ☁️Cloud Operators
    • Launching the Exchange
    • Setting Domain for Cloud Exchanges
    • Easy SMTP for Cloud Exchanges
    • SEO Settings for Cloud Exchanges
      • SEO Advanced Settings
  • ⚙️Operating Your Exchange
    • Operator Control Panel
      • General
      • Users
      • User Profile
      • Assets
      • Markets
      • Stakes
      • Sessions
      • Plugins Apps
      • Trading Fees & Account Tiers
      • Roles
      • Chat
      • Billing
    • Customize Exchange
      • Browser Tools
        • Enter Edit Mode
        • Operator Controls (Visuals)
        • Console
      • Plugins
      • Forked Repo
    • Fiat Controls
      • Initial Setup
      • Setting Up Fiat On/ Off Ramp
      • Editing Deposit & Withdrawal Fees
      • Users Making Fiat Deposit
      • Users Trading With Fiat
      • User Making Fiat Withdrawal
    • Staking
    • OTC Broker
    • P2P
      • P2P Overview
      • P2P Setup
      • P2P Troubleshooting
      • P2P Vendor Flow
    • Smart Chain Trading
    • Assets & Trading Pairs
      • Add New Assets & Trading Pairs
      • Configure Pair Parameters
    • Set up the SMTP Email
      • Set up SMTP with AWS SES
      • Set up SMTP with Mailgun
      • Set up SMTP with SendGrid
      • Test the SMTP with Gmail
    • Enabling reCAPTCHA
    • Email Customization & Audit
    • DeFi Asset Staking Process
  • 🧩Plugins
    • HollaEx Plugins
      • Announcements
      • Bank
      • AWS SNS (Text Messages - SMS)
      • KYC
      • Automatic KYC
      • Messente
      • Advanced Referral
      • CoinMarketCap
      • Guardarian
    • Install Plugins
    • Developing Plugins
      • Development Walkthrough: Hello-Plugin
        • Initialization
        • Configuration
        • Scripting
        • Web View
        • The Final Product & Installation
      • Advanced
        • Initialization
        • Config
        • Server Script
        • Plugin Libraries
        • Web View
        • Final Plugin Product
        • Advanced Tutorial: Using the user meta field
        • Advanced Tutorial: Adding a new database table column
        • Advanced Tutorial: Creating a new database table
      • Simple Wallet Example
      • Web View Development
        • Overview
        • External dependencies
        • Getting started
        • Basic Tutorial: Hello Exchange Plugin web view
        • Advanced Tutorial: KYC Plugin web views
    • Bank Integration
      • Handling Deposits
      • Handling Withdrawals
  • 👷Developers
    • API Guide
      • API Example Scripts
    • Run Dev Mode
    • Build a New Front-end Interface
  • 🧰On-Premise Operators (Advanced Only)
    • On-Premise Exchange Setup
      • Getting Started — Requirements
      • Installation
      • Server Setup
      • Web Setup
      • Production
    • CLI How-Tos
      • Start Exchange
      • Stop Exchange
      • Upgrade Exchange
        • Build and Apply the Code Changes
      • Get Exchange Logs
      • Get a Backup and Restore
      • Exchange Migration
      • Command List
    • Run Exchange on Kubernetes
    • Troubleshooting Guide
  • 🚀Advanced
    • SEO Optimization
    • Nginx
    • Rate Limits
    • Database
      • Upgrade Database
    • Dependencies
    • Contents Delivery Network
      • Cloudflare CDN for HollaEx
      • CloudFront CDN for HollaEx
    • Load Balancer
      • AWS ELB
      • DigitalOcean LB
    • Customize Kubenretes Ingress
    • Exchange Keys
      • Exchange API Keys Troubleshoot
    • HollaEx on non-Linux
      • HollaEx on Windows
      • HollaEx on macOS
    • The Network Tool Library
      • Accessing the Network Tool Library
      • Functions
        • WebSocket
      • Simple Example: Creating a User and Wallet
      • Getting More Interesting: Orders with the Tools
        • Setup: Using the transferAsset function
        • Creating and Monitoring a Sell Order
        • Settling Fees
      • Private HollaEx Network
    • Docker Content Trust (DCT)
    • Revenue Sharing
  • 📦Releases
    • Release Notes
    • Side Notes
  • ➡️External Links
  • Blogs
  • Forum
  • Videos
  • Twitter X
  • Telegram
  • Interactive Demo
  • Discord Community
  • API Documentation
  • Tools Library Documentation
  • Node Library Documentation
  • Plugins Documentation
Powered by GitBook
On this page
  • Functions
  • Channels
  • Events
  1. Advanced
  2. The Network Tool Library
  3. Functions

WebSocket

Through WebSocket connections real-time updates can be obtained from a variety of sources

Functions

You can connect and subscribe to different WebSocket channels for real-time updates.

To connect, use the connect function with the channels you want to subscribe to in an array as the parameter. The connection will reconnect on its own unless you call disconnect.

client.connect(['orderbook', 'trade']);

To disconnect the WebSocket, call disconnect.

client.disconnect();

To subscribe to more channels after connection, use subscribe.

client.subscribe(['order:1', 'wallet:1']);

To unsubscribe from channels after connection, use unsubscribe.

client.unsubscribe(['orderbook'])

Channels

Here is the list of channels you can subscribe to:

  • orderbook

  • trades

  • order (Only available with authentication. Receive order updates for a user of your exchange)

  • wallet (Only available with authentication. Receive balance updates for a user of your exchange)

For public channels (orderbook, trade), you can subscribe to specific symbols as follows: orderbook:xht-usdt, trade:xht-usdt. Not passing a symbol will subscribe to all symbols.

For private channels (order, trade), you must also pass the user's ID on the HollaEx Network as follows: order:1, wallet:23. Not passing an ID will give an error.

Events

After connecting to the WebSocket, you can listen for events coming from the server by using the on function for the ws property of the client. The events available are default WebSocket events e.g. message, open, close, error, unexpected-response, etc.

client.ws.on('message', (data) => {
	data = JSON.parse(data);
	console.log(data);
});

These are examples of data responses from the server.

orderbook: Updates related to the user's private information are as follows:

{
 	"topic": "orderbook",
 	"action": "partial",
 	"symbol": "xht-usdt",
 	"data": {
 		"bids": [
 			[0.1, 0.1],
 			...
 		],
 		"asks": [
 			[1, 1],
 			...
 		],
 		"timestamp": "2020-12-15T06:45:27.766Z"
 	},
 	"time": 1608015328
 }

trade: Updates related to the user's private information are as follows:

 {
 	"topic": "trade",
 	"action": "partial",
 	"symbol": "xht-usdt",
 	"data": [
 		{
 			"size": 0.012,
 			"price": 300,
 			"side": "buy",
 			"timestamp": "2020-12-15T07:25:28.887Z"
 		},
 		...
 	],
 	"time": 1608015328
 }

wallet: Updates related to the user's private information are as follows:

 {
 	"topic": "wallet",
 	"action": "partial",
 	"user_id": 1,
 	"data": {
 		"usdt_balance": 1,
 		"usdt_available": 1,
 		"xht_balance": 1,
 		"xht_available": 1,
 		"xmr_balance": 1,
 		"xmr_available": 1,
 		"btc_balance": 1,
 		"btc_available": 1,
 		"eth_balance": 1,
 		"eth_available": 1,
 		...,
 		"updated_at": "2020-12-15T08:41:24.048Z"
 	},
 	"time": 1608021684
 }

order: Websocket messages relating to the user's orders.

  • The status of the order can be new, pfilled, filled, and canceled.

  • The action of the data determines what caused it to happen. All three are explained below:

  • partial: All previous and current orders. Is the first order data received when connecting. Max: 50. Descending order.

{
	"topic": "order",
	"action": "partial",
	"user_id": 1,
	"data": [
		{
			"id": "7d3d9545-b7e6-4e7f-84a0-a39efa4cb173",
			"side": "buy",
			"symbol": "xht-usdt",
			"type": "limit",
			"size": 0.1,
			"filled": 0,
			"price": 1,
			"stop": null,
			"status": "new",
			"fee": 0,
			"fee_coin": "xht",
			"meta": {},
			"fee_structure": {
				"maker": 0.1,
				"taker": 0.1
			},
			"created_at": "2020-11-30T07:45:43.819Z",
			"created_by": 1
		},
		...
	],
	"time": 1608022610
}

insert: When user's order is added. The status of the order can be either new, pfilled, or filled.

{
	"topic": "order",
	"action": "insert",
	"user_id": 1,
	"symbol": "xht-usdt",
	"data": [
		{
			"id": "7d3d9545-b7e6-4e7f-84a0-a39efa4cb173",
			"side": "buy",
			"symbol": "xht-usdt",
			"type": "limit",
			"size": 0.1,
			"filled": 0,
			"price": 1,
			"stop": null,
			"status": "new",
			"fee": 0,
			"fee_coin": "xht",
			"meta": {},
			"fee_structure": {
				"maker": 0.1,
				"taker": 0.1
			},
			"created_at": "2020-11-30T07:45:43.819Z",
			"updated_at": "2020-12-15T08:56:45.066Z",
			"created_by": 1
		},
		...
	],
	"time": 1608022610
}

update: When user's order status is updated. Status can be pfilled, filled, and canceled.

{
	"topic": "order",
	"action": "insert",
	"user_id": 1,
	"symbol": "xht-usdt",
	"data": [
		{
			"id": "7d3d9545-b7e6-4e7f-84a0-a39efa4cb173",
			"side": "buy",
			"symbol": "xht-usdt",
			"type": "limit",
			"size": 0.1,
			"filled": 0,
			"price": 1,
			"stop": null,
			"status": "new",
			"fee": 0,
			"fee_coin": "xht",
			"meta": {},
			"fee_structure": {
				"maker": 0.1,
				"taker": 0.1
			},
			"created_at": "2020-11-30T07:45:43.819Z",
			"updated_at": "2020-12-15T08:56:45.066Z",
			"created_by": 1
		},
		...
	],
	"time": 1608022610
}
PreviousFunctionsNextSimple Example: Creating a User and Wallet

Last updated 2 years ago

🚀