Using Nodejs Library

Connect with Fine Exchange using Hollaex kit Nodejs Library

Requirements

  • Knowledge of basic usage of nodejs and npm
  • Nodejs version >= 12
  • Install hollaex-node-lib by running npm i hollaex-node-lib or yarn add hollaex-node-lib in your project

Usage

Connecting with any Hollaex Kit Enabled Exchange is pretty much same, with minor modifications you can connect to all the exchanges that uses similar Hollaex Kit backends.

Import Library

const kit = require('hollaex-node-lib');

const client = new kit({
	apiURL: 'https://api.fine.exchange',
	baseURL: '/v2',
	apiKey: '<MY_API_KEY>',
	apiSecret: '<MY_API_SECRET>'
});

Put Api Key for <MY_API_KEY> & Api Secret for <MY_API_SECRET> in above code that you can get from the guide.

Request structure

// Initialize Client using above example...

client
	.getTicker('xht-usdt')
	.then((res) => {
		console.log('The volume is: ', res.volume);
	})
	.catch((err) => {
		console.log(err);
	});

client
	.getTrade({ symbol: 'xht-usdt' })
	.then((res) => {
		console.log('Public trades: ', res);
	})
	.catch((err) => {
		console.log(err);
	});

Available methods

  • Optional parameters are all contained within an object parameter called opts
CommandParametersDescription
getKitGet exchange information e.g. name, valid languages, description, etc.

getConstantsTick size, min price, max price, min size and max size of each symbol pair and coin

getTickersymbolLast, high, low, open and close price and volume within the last 24 hours

getTickersLast, high, low, open and close price and volume within the last 24 hours for all symbols

getOrderbooksymbolOrderbook containing list of bids and asks

getOrderbooksOrderbook containing list of bids and asks for all symbols

getTradesymbol (optional)List of last trades
getUserUser’s personal information
getBalanceUser’s wallet balance
getDepositscurrency (optional), limit (optional, default=50, max=100), page (optional, default=1), orderBy (optional, default=id), order (optional, default=asc, asc or desc), startDate (optional, default=0, format=ISO8601), endDate (optional, default=NOW, format=ISO8601)

User’s list of all deposits
getWithdrawalscurrency (optional), limit (optional, default=50, max=100), page (optional, default=1), orderBy (optional, default=id), order (optional, default=asc, asc or desc), startDate (optional, default=0, format=ISO8601), endDate (optional, default=NOW, format=ISO8601)User’s list of all withdrawals
requestWithdrawalcurrency, amount, address (receipient’s)Create a new withdrawal request. Disable Two-Factor Authentication to be able to use this function. Must confirm within 5 minutes via email to complete withdrawal
getUserTradessymbol (optional), limit (optional, default=50, max=100), page (optional, default=1), orderBy (optional, default=id), order (optional, default=desc, asc or desc), startDate (optional, default=0, format=ISO8601), endDate (optional, default=NOW, format=ISO8601)User’s list of all trades
getOrderorderIdGet specific information about a certain order
getOrderssymbol (optional), limit (optional, default=50, max=100), page (optional, default=1), orderBy (optional, default=id), order (optional, default=desc, enum=asc, desc), startDate (optional, default=0, format=ISO8601), endDate (optional, default=NOW, format=ISO8601)

Get the list of all user orders. It can be filter by passing the symbol
createOrdersymbol, side (buy or sell), size, type (market or limit), price, stop (optional), meta (optional, object with optional properties e.g. post_only)Create a new order
cancelOrderorderIdCancel a specific order with its ID
cancelAllOrderssymbol (optional)Cancel all open order. It can be filter by passing the symbol


Fine Exchange is Hollaex Kit Enabled Exchange so you can read about more for API usage, instructions & examples from Github Repo


Websocket client

To create custom websocket client, Please visit the guide, This guide uses hollaex-node-lib and assumes that you have already configured your code to assign client variable/constant (as shown above) before trying this.

To make a connection:

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

To disconnect it:

new_connetion.disconnect();

Channel subscriptions

You can subscribe to following channels

  • orderbook
  • trades
  • order (Only available with authentication. Receive order updates)
  • wallet (Only available with authentication. Receive balance updates)

Listen to events

After connection, You can listen for these events from the server by using on method, e.g.

  • message
  • open
  • close
  • error
  • unexpected-response etc.

Example

// Initialize Client using above example...
const socket1 = client.connect('trades:xht-usdt');

socket1.on('trades', (data) => {
	console.log(data);
});

const socket2 = client.connect('all');

socket2.on('orderbook', (data) => {
	console.log(data);
});

// You have to use a token to use these  otherwise the socket disconnects
socket2.on('userInfo', (data) => {
	console.log(data);
});


setTimeout(() => {
	socket2.disconnect();
}, 5);

Resources