Nodejs library for HollaEx Kit enabled exchanges.
This library is specifically for end users and traders to connect to HollaEx Kit exchanges. It connects to HollaEx Pro by default.
const hollaex = require('hollaex-node-lib');
const client = new hollaex();
You can pass custom apiURL
, wsURL
and baseURL
of the HollaEx-Enabled exchange to connect to. apiURL
is https://api.hollaex.com
for HollaEx Pro and for your custom exchange it would be something like https://myexchange.com/api
.
wsURL
is the websocket URL for the socket connection and you should pass your stream URL. For HollaEx Pro it is wss://api.hollaex.com/stream
and for your exchange it would be something like wss://myexchange.com/stream
. baseURL
is not required and it is set by default to /v2
unless you need to connect to an older version of HollaEx.
You can also pass your apiKey
and apiSecret
generated from the HollaEx-Enabled exchange to use private requests that require authentication. For public endpoints apiKey
and apiSecret
are not required.
const client = new hollaex({
apiURL: '<EXCHANGE_API_URL>',
wsURL: '<EXCHANGE_WS_URL>',
apiKey: '<MY_API_KEY>',
apiSecret: '<MY_API_SECRET>'
});
You can also pass the field apiExpiresAfter
which is the length of time in seconds each request is valid for. The default value is 60
.
const client = new hollaex({
apiURL: '<EXCHANGE_API_URL>',
wsURL: '<EXCHANGE_API_URL>',
apiKey: '<MY_API_KEY>',
apiSecret: '<MY_API_SECRET>'
});
client
.getTicker('xht-usdt')
.then((res) => {
console.log('The volume is: ', res.volume);
})
.catch((err) => {
console.log(err);
});
client
.getTrades({ symbol: 'xht-usdt' })
.then((res) => {
console.log('Public trades: ', res);
})
.catch((err) => {
console.log(err);
});
Command | Parameters | Description |
---|---|---|
getKit |
Get exchange information e.g. name, valid languages, description, etc. | |
getConstants |
Tick size, min price, max price, min size and max size of each symbol pair and coin | |
getTicker |
|
Last, high, low, open and close price and volume within the last 24 hours |
getTickers |
Last, high, low, open and close price and volume within the last 24 hours for all symbols | |
getOrderbook |
|
Orderbook containing list of bids and asks |
getOrderbooks |
Orderbook containing list of bids and asks for all symbols | |
getTrades |
|
List of last trades |
getUser |
User's personal information | |
getBalance |
User's wallet balance | |
getDeposits |
|
User's list of all deposits |
getWithdrawals |
|
User's list of all withdrawals |
makeWithdrawal |
|
Create a new withdrawal request |
getUserTrades |
|
User's list of all trades |
getOrder |
|
Get specific information about a certain order |
getOrders |
|
Get the list of all user orders. It can be filter by passing the symbol |
createOrder |
|
Create a new order |
cancelOrder |
|
Cancel a specific order with its ID |
cancelAllOrders |
|
Cancel all the active orders of a user, filtered by currency pair symbol |
getMiniCharts |
|
Get trade history HOLCV for all pairs |
getQuickTradeQuote |
|
Get Quick Trade Quote |
executeOrder |
|
Execute Order |
Command | Parameters | Description |
---|---|---|
getExchangeInfo |
Get admin exchange information | |
getExchangeDeposits |
|
Retrieve list of the user's deposits by admin |
getExchangeWithdrawals |
|
Retrieve list of the user's withdrawals by admin |
getExchangeBalance |
Retrieve admin's wallet balance | |
transferExchangeAsset |
|
Transfer exchange asset by admin |
createExchangeDeposit |
|
Create exchange deposit by admin |
updateExchangeDeposit |
|
Update exchange deposit by admin |
createExchangeWithdrawal |
|
Create exchange withdrawal by admin |
updateExchangeWithdrawal |
|
Update Exchange Withdrawal |
checkExchangeDepositStatus |
|
Check exchange deposit status |
settleExchangeFees |
|
Set exchange fees by admin |
getExchangeTrades |
|
Retrieve user's trades by admin |
getExchangeOrders |
|
Retrieve user's orders by admin |
cancelExchangeUserOrder |
|
Cancel user's order by order id |
getExchangeUsers |
|
Retrieve list of the user info by admin |
createExchangeUser |
|
Create exchange user |
updateExchangeUser |
|
Update exchange user |
createExchangeUserWallet |
|
Create wallet for exchange user |
getExchangeUserWallet |
|
Retrieve users' wallets by admin |
getExchangeUserBalance |
|
Retrieve user's login info by admin |
createExchangeUserBank |
|
Create bank account for user by admin |
getExchangeUserLogins |
|
Retrieve user's login info by admin |
deactivateExchangeUser |
|
Deactivate exchange user account by admin |
deactivateExchangeUserOtp |
|
Deactivate user otp by admin |
getExchangeUserReferrals |
|
Retrieve user's referrals info by admin |
getExchangeUserReferrer |
|
Retrieve user's referer info by admin |
sendExchangeUserEmail |
|
Send email to exchange user account by admin |
sendRawEmail |
|
Send email to users with custom html by admin |
getOraclePrice |
|
Retrieve price conversion |
getExchangeUserBalances |
|
Retrieve user's balances by admin |
You can connect and subscribe to different websocket channels for realtime 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 it's 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', 'wallet']);
To unsubscribe from channels after connection, use unsubscribe
.
client.unsubscribe(['orderbook']);
Here is the list of channels you can subscribe to:
orderbook
(Available publicly)trade
(Available publicly)order
(Only available with authentication. Receive order updates)usertrade
(Only available with authentication. Receive user trades)wallet
(Only available with authentication. Receive balance updates)deposit
(Only available with authentication. Receive deposit notifications)withdrawal
(Only available with authentication. Receive withdrawal notifications)admin
(Only available with authentication for the exchange administrator. Receive exchange operations such as deposits and withdrawals of all users)
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.
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 exapmles 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 the the user's orders.
-
The
status
of the order can benew
,pfilled
,filled
, andcanceled
. -
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 eithernew
,pfilled
, orfilled
.{ "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 bepfilled
,filled
, andcanceled
.{ "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 }
-
-
deposit: Updates related to the user's private information are as follows:
{ "topic": "deposit", "action": "insert", "user_id": 1, "data": { "amount": 1, "currency": "xht", "status": "COMPLETED", "transaction_id": "123", ... }, "time": 1608021684 }
-
withdrawal: Updates related to the user's private information are as follows:
{ "topic": "withdrawal", "action": "insert", "user_id": 1, "data": { "amount": 1, "currency": "xht", "status": "COMPLETED", "transaction_id": "123", ... }, "time": 1608021684 }
You can run the example by going to example folder and running:
node example/hollaex.js
For adding additional functionalities simply go to index.js and add more features. You can read more about api documentation at https://apidocs.hollaex.com You should create your token on the platform in setting->api keys