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
  • Get Sign Ups
  • Reward New Users with USDT
  • Alert Admin to Large Deposits
  • Send Custom HTML Email to New Users
  • Find the Most Active Trader
  1. Developers
  2. API Guide

API Example Scripts

Here are a few examples of some useful real-life scripts that could be implemented using the HollaEx API

Here are some more complex scripts that following the process on the previous page could be implemented and make your life easier.

Get Sign Ups

Retrieve the number of user sign-ups per month

const hollaex = require("hollaex-node-lib");

const client = new hollaex({
  apiURL: "<YOUR_EXCHANGES_URL>",
  apiKey: "<USER_API_KEY>",
  apiSecret: "<USER_API_KEY_SECRET>",
});

//Get the number of exchange user signups by each month.
const getSignups = async () => {
	try {
		const months= ["January","February","March","April","May","June",
		"July",	"August","September","October","November","December"];

		const signups = {};

		for(let i = 0; i < months.length; i++) {
		const date = new Date();
		const month = date.setMonth(date.getMonth() - i);
code
		const res = await client.getExchangeUsers({ startDate: new Date(month) });
		signups[`${months[date.getMonth()]}- ${date.getFullYear()}`] = res.data.length;
		
		}

		return signups;
	} catch (error) {
		return error.message;
	}
}


getSignups().then(res => console.log(res);

Reward New Users with USDT

Once users verify their account, deposit 5 USDT into their USDT wallet

const hollaex = require("hollaex-node-lib");

const client = new hollaex({
  apiURL: "<YOUR_EXCHANGES_URL>",
  apiKey: "<USER_API_KEY>",
  apiSecret: "<USER_API_KEY_SECRET>",
});

//Get newly registered users of last month and give them 5 USDT gift.
const sendUsdtToVerifiedUsers = async () => {
	try {
		const date = new Date();
		const lastMonth = date.setMonth(date.getMonth() - 1);

		const res = await client.getExchangeUsers({ startDate: new Date(lastMonth) });

		for(const user of res.data) {
			await client.createExchangeDeposit(user.id, 'usdt', 5);
		}
	} catch (error) {
		return error.message;
	}
}

sendUsdtToVerifiedUsers().then(res => console.log(res);

Alert Admin to Large Deposits

Notify the admin by email if a deposit of over $10,000 worth is made, and give the details of the deposit

const hollaex = require("hollaex-node-lib");

const client = new hollaex({
  apiURL: "<YOUR_EXCHANGES_URL>",
  wsURL: "<YOUR_EXCHANGE_WS_URL>",
  apiKey: "<USER_API_KEY>",
  apiSecret: "<USER_API_KEY_SECRET>",
});

//Send a custom alert email to the exchange administrator if there is a deposit of more than $10,000 to the exchange of any coin.
const sendCustomAlertMail = async () => {
	try {
		const date = new Date();
		const lastMonth = date.setMonth(date.getMonth() - 1);

		const deposits = await client.getExchangeDeposits({ format:'all', startDate: new Date(lastMonth) });
		const conversions = await client.getOraclePrice([...new Set(deposits.data.map(deposit => deposit.currency))], { quote: 'usdt', amount: 1 });

		for(const deposit of deposits.data) {
			if(conversions[deposit.currency] * deposit.amount > 10000) {
				await client.sendExchangeUserEmail(1, "alert", 
				{
					"type": "Deposit more than $10,000 detected",
					"data": `We detected a deposit worth more than $10,000 from last month, 
						Currency: ${deposit.currency}, Amount: $${conversions[deposit.currency] * deposit.amount}, User_id: $${deposit.user_id}, Deposit creation date: ${deposit.created_at}`
				})
			}
		}
	} catch (error) {
		return error.message;
	}
}

sendCustomAlertMail().then(res => console.log(res);

Send Custom HTML Email to New Users

With the HTML of an email contained in a variable, send this HTML as an email to all new users

const hollaex = require("hollaex-node-lib");

const client = new hollaex({
  apiURL: "<YOUR_EXCHANGES_URL>",
  apiKey: "<USER_API_KEY>",
  apiSecret: "<USER_API_KEY_SECRET>",
});

//Send a custom raw email every day to users who signed up with the last 24 hours to welcome them to the exchange.
const sendCustomRawEmail = async () => {
	try {
		const date = new Date();
		const last24Hours = date.setHours(date.getHours() - 24);

		let users = await client.getExchangeUsers({ startDate: new Date(last24Hours) })
		
		const htmlContent = "<div><b>Welcome to the exchange again!</b></div>";
	
	await client.sendRawEmail(
		users.data.map(user => user.email), 
		htmlContent,
		{ title : 'Welcome' });
	} catch (error) {
		return error.message;
	}
}

sendCustomRawEmail().then(res => console.log(res);

Find the Most Active Trader

Find the user who has traded the highest volume over all assets in the past month

const hollaex = require("hollaex-node-lib");

const client = new hollaex({
  apiURL: "<YOUR_EXCHANGES_URL>",
  apiKey: "<USER_API_KEY>",
  apiSecret: "<USER_API_KEY_SECRET>",
});

// Find the most active trader on the exchange with the highest volume in the last one month of exchange operation.
const getTradeWithMostVolume = async () => {
	try {
		const date = new Date();
		const lastMonth = date.setMonth(date.getMonth() - 1);
	
		let trades = await client.getExchangeTrades({ startDate: new Date(lastMonth), format: 'all' });


		const userVolumes = {}
		const coins = [];

		const setUserVolumes = (traderId, symbol, size) => {
			if(!userVolumes[traderId]) userVolumes[traderId] = {}
			if(!userVolumes[traderId][symbol]) userVolumes[traderId][symbol] = 0;
			userVolumes[traderId][symbol] += size
		}

		
		if(trades.data.length > 0){
			for (const trade of trades.data) {
				const tradeCoin = trade?.symbol?.split('-')?.[0];
				if(!coins.includes(tradeCoin)) coins.push(tradeCoin);
				if (trade.maker_id != null && !isNaN(trade.maker_id)) {
					setUserVolumes(trade.maker_id, tradeCoin, trade.size);
				}
				if (trade.taker_id != null && !isNaN(trade.taker_id)) {
					setUserVolumes(trade.taker_id, tradeCoin, trade.size);
				}
			}

			const conversions = await client.getOraclePrice(coins, { quote: 'usdt', amount: 1 });

			let highestTrader = { userId: null,  volume: 0 };
			for ([userId, tradeObject] of Object.entries(userVolumes)) {
				for  ([symbol, size] of Object.entries(tradeObject)) {
					
					const conversion = conversions[symbol] * size;
					userVolumes[userId][symbol] = conversion;
						 
					if (highestTrader.volume < conversion) {
						highestTrader.userId = userId;
						highestTrader.coin = symbol;
						highestTrader.volume =conversion;
					}
					
				}
			}
			return highestTrader;
		}
		else { return 'Trade not found'; }
	} catch (error) {
		return error.message;
	}
}

getTradeWithMostVolume().then(res => console.log(res);
PreviousAPI GuideNextRun Dev Mode

Last updated 1 year ago

👷