1.0.1 • Published 5 years ago
node-axnet-api v1.0.1
Node AXNET API
This is npm package to help users who want to develop apps using AXNET APIs.
The AXNET APIs are designed to allow access to all of the features of the AXNET platform. The end goal is to allow people to potentially recreate the entire platform on their own.
Installation
npm install node-axnet-api --save
Getting started
You can get class of node-axnet-api and create instance with some parameters. Here important fields are APIKEY and APISECRET, which are neccessary for API authorization. You can get them from user profile of AXNET site.
const AXNET = require('node-axnet-api');
const axnet = new AXNET(
{
APIKEY: '<key>',
APISECRET: '<secret>',
requestTimeout: 10000
});
APIs
Get all markets symbol pairs
axnet.getSymbols()
.then(symbols => {
console.log("Symbols: ", symbols);
})
.catch(e => {
console.log("error: ", e);
})
Get all markets info
axnet.getMarkets()
.then(markets => {
console.log("Markets: ", markets);
})
.catch(e => {
console.log("error: ", e);
})
Get your current balance
axnet.getBalance()
.then(balance => {
console.log("balance: ", balance);
})
.catch(e => {
console.log("error: ", e);
})
Get your open orders
axnet.getMyOpenOrders()
.then(orders => {
console.log("open orders: ", orders);
})
.catch(e => {
console.log("error: ", e);
})
Send order
let orderData = {};
orderData.orderType = 'LIMIT';
orderData.token = 'ETH';
orderData.baseToken = 'BTC';
orderData.amount = 0.0001;
orderData.price = 0.05;
orderData.direction = 1;
axnet.sendOrder(orderData)
.then(order => {
console.log("order result: ", order);
})
.catch(e => {
console.log("error: ", e);
})
Cancel order
axnet.cancelOrder(orderObject._id)
.then(order => {
console.log("order canceled: ", order);
})
.catch(e => {
console.log("error: ", e);
})
Websocket stream
On order Updated
axnet.onUpdateOrderSocket(order => {
console.log("order updated: ", order);
})
On balance Updated
axnet.onUpdateBalanceSocket(balance => {
console.log("balance updated: ", balance);
})
On new trade
axnet.onTradeSocket(trade => {
console.log("new trade: ", trade);
})