1.3.9 • Published 6 years ago

acx v1.3.9

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

alt text

ACX API & WebSocket Utilities

GitHub last commit npm npm npm

This projectis designed to help you make your own projects that interact with the ACX Exchange.

ACX is ambitious, awesome, advanced and Australian. Since 2013, we've taken the complexity out of trading and owning digital currencies for everyone in Australian and beyond. Our goal at ACX is to provide the highest quality, instant and simplified purchasing experience for customers looking to acquire Blockchain Backed assets, starting with Bitcoin.

Read Full Usage Guide On GitHub

What's new npm

  • New parameter "market" has been introduced in clearOrder request.
  • New function "deleteOrders" which allow user to cancel multiple orders.

Getting started

Installation

npm install acx --save

Prerequisites

To get started, you need to request for access/secret key at first. Please visit ACX API Reference for more information.

REST API Usage

Initialise

parametertyperequired?description
marketStringrequiredmarkets available in ACX, All available markets can be found at ACX API Reference.
access_keyStringrequiredaccess key gain from ACX.io
secret_keyStringrequiredsecret key gain from ACX.io
tradeFeeFloatoptionalACX trading fee, default value is 0.002 which is 0.2%
restApiEndPointStringoptionalACX default rest API uri, default is https://acx.io:443
socketEndPointStringoptionalACX default WebSocket end point, default is wss://acx.io:8080
const ACX = require('acx');
var acx = new ACX({maret:"dashbtc", access_key:<access_key>, secret_key:<secret_key>);
const ACX = require('acx');
var acx = new ACX({maret:"dashbtc", access_key:<access_key>, secret_key:<secret_key>, tradeFee:0.001);

Functions

Get my account information

acx.getMyAccount().then(data => {
    console.log(data);
}).catch(e => { console.error(e); });

Get recent trades on the market

parametertyperequired?description
marketStringoptionalMarket you want to get trades from, default to the one specified on initialization.
order_byStringoptionalIf set, returned trades will be sorted in specific order, default to 'desc'(reverse creation order).
limitIntegeroptionalLimit the number of returned trades. Default to 50.
fromIntegeroptionalTrade id. If set, only trades created after the trade will be returned.
toIntegeroptionalTrade id. If set, only trades created before the trade will be returned.
timestampIntegeroptionalAn integer represents the seconds elapsed since Unix epoch. If set, only trades executed before the time will be returned.
acx.getMarketTrades().then(data => {
    console.log(data)
}).catch(e => { console.error(e); });
acx.getMarketTrades({from:7476198, order_by:'asc'}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });
acx.getMarketTrades({timestamp:1522904400}).then(data => {
    console.log(data);
}).catch(e => { console.error(e); });

Get my trade history

Get recent 50 trades in descending order.

parametertyperequired?description
marketStringoptionalMarket you want to get trades from, default to the one specified on initialization.
order_byStringoptionalIf set, returned trades will be sorted in specific order, default to 'desc'(reverse creation order).
limitIntegeroptionalLimit the number of returned trades. Default to 50.
fromIntegeroptionalTrade id. If set, only trades created after the trade will be returned.
toIntegeroptionalTrade id. If set, only trades created before the trade will be returned.
timestampIntegeroptionalAn integer represents the seconds elapsed since Unix epoch. If set, only trades executed before the time will be returned.
acx.getMyTrades().then(data => {
    console.log(data);
}).catch(e => { console.error(e); });

You can also specify other parameters to narrow down results.

acx.getMyTrades({from:7476198, order_by:'asc'}).then(data => {
    console.log(data);
}).catch(e => { console.error(e); });
acx.getMyTrades({timestamp:1522904400}).then(data => {
    console.log(data);
}).catch(e => { console.error(e); });

Get my open orders

Get my recent open orders.

parametertyperequired?description
marketStringoptionalMarket you want to get trades from, default to the one specified on initialization.
order_byStringoptionalIf set, returned trades will be sorted in specific order, default to 'desc'(reverse creation order).
limitIntegeroptionalLimit the number of returned trades. Default to 50.
stateStringoptionalFilter order by state, default to 'wait' (active orders).
pageIntegeroptionalSpecify the page of paginated results.
acx.getOrders().then(data => {
    console.log(data)
}).catch(e => { console.error(e); });
acx.getOrders().then(data => {
    console.log(data)
}).catch(e => { console.error(e); });
acx.getOrders({ state: 'wait' }).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });
acx.getOrders({ limit: 2, page: 2 }).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Update my order by order id

This function has been abandoned.

Get my orders by order id

Get information of specified order by order id

parametertyperequired?description
order_idIntegerrequiredUnique order id.
acx.getOrderById(536786).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Get my deposits history

Get my deposits history by currency value(contains btc, aud, bch, eth, hsr, fuel, ubtc, eet, dash).

parametertyperequired?description
currencyStringOptionalcurrency value(contains btc, aud, bch, eth, hsr, fuel, ubtc, eet, dash).
limitIntegeroptionalSet result limit.
stateStringoptionalFilter deposits by state.
acx.getDeposits().then(data=>{
    console.log(data)
}).catch(e => { console.error(e); });
acx.getDeposits({ currency: 'aud' }).then(data=>{
    console.log(data)
}).catch(e => { console.error(e); });
acx.getDeposits({ state: 'submitting', limit: 10 }).then(data=>{
    console.log(data)
}).catch(e => { console.error(e); });

Get my deposit by txid

parametertyperequired?description
txidStringRequiredtransaction ID
acx.getDeposit('mock29c5de23a0dfc10648fb5f128ff5bd140e153a5a99d0208b9f3d755e29721137').then(data => {
    console.log(data)
});

Get my deposit address by currency

parametertyperequired?description
currencyStringOptionalcurrency value(contains btc, aud, bch, eth, hsr, fuel, ubtc, eet, dash). Default to 'aud'.
acx.getDepositAddress('btc').then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Create multiple sell/buy orders

Create multiple sell/buy orders by list of order objects. Response status message will be displayed.

parametertyperequired?description
sideStringoptionalEither 'sell' or 'buy'.
priceFloatoptionalPrice for each unit. Leave empty to place market order
volumeFloatoptionalThe amount user want to sell/buy. An order could be partially executed, e.g. an order sell 5 btc can be matched with a buy 3 btc order, left 2 btc to be sold; in this case the order's volume would be '5.0', its remaining_volume would be '2.0', its executed volume is '3.0'.
acx.placeOrders([
        {side: 'sell', price: 0.04452900, volume: 0.1},
        {side: 'sell', price:0.04452800, volume: 0.2}
    ]).then(data => { console.log(data)
}).catch(e => { console.error(e); });

Cancel an order

Cancel a specific order by order id

parametertyperequired?description
order_idIntegerrequiredUnique order id.
acx.deleteOrder(536791).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Bulk cancel orders

Delete orders by ids

parametertyperequired?description
idsStringrequiredA String of order Ids joined by ',' , for instance: 23,24,26
acx.deleteOrders('23,24,26').then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Clear orders

parametertyperequired?description
marketStringoptionalMarket you want to get data from, default to the one specified on initialization. If present, only specified market orders will be canncelled.
sideStringoptionalEither 'sell' or 'buy'.
acx.clearOrders();
acx.clearOrders().then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Alternatively, you can also cancel your orders by market and side(buy/sell)

acx.clearOrders({market: 'btcaud', side:'buy'}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Get order book by market

parametertyperequired?description
marketStringoptionalMarket you want to get data from, default to the one specified on initialization.
asks_limitIntegeroptionalLimit the number of returned sell orders. Default to 20.
bids_limitIntegeroptionalLimit the number of returned buy orders. Default to 20.
acx.getOrderBook({market:'btcaud'}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });
acx.getOrderBook({market:'btcaud', asks_limit:10, bids_limit: 20}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Function will return the order book for the market which you have defined when you create the acx object if you haven't specified the market parameter.

acx.getOrderBook().then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Get market depth

parametertyperequired?description
marketStringoptionalMarket you want to get data from, default to the one specified on initialization.
limitIntegeroptionalLimit the number of returned price levels. Default to 300.
acx.getDepth({market:'btcaud'}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });
acx.getDepth({market:'btcaud', limit:1000}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Function will return the depth of the market which you have defined when you create the acx object if you haven't specified the market parameter.

acx.getDepth().then(data => {
    console.log(data)
}).catch(e => { console.error(e); });
acx.getDepth({limit:1000}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Get OHLC(K Line) of specific market

parametertyperequired?description
marketStringoptionalMarket you want to get data from, default to the one specified on initialization.
limitIntegeroptionalLimit the number of returned data points. Default to 30.
periodIntegeroptionalTime period of K line, default to 1. You can choose between 1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10080
timestampIntegeroptionalAn integer represents the seconds elapsed since Unix epoch. If set, only k-line data after that time will be returned.
//Time period of K line, default to 1. You can choose between 1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10080
acx.getKLine({period:5}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Function will return the OHLC of the market which you have defined when you create the acx object if you haven't specified the market parameter.

acx.getKLine().then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Get K data with pending trades

Get K data with pending trades, which are the trades not included in K data yet, because there's delay between trade generated and processed by K data generator.

parametertyperequired?description
trade_idIntegerrequiredThe trade id of the first trade you received.
marketStringoptionalMarket you want to get data from, default to the one specified on initialization.
limitIntegeroptionalLimit the number of returned data points. Default to 30.
periodIntegeroptionalTime period of K line, default to 1. You can choose between 1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10080
timestampIntegeroptionalAn integer represents the seconds elapsed since Unix epoch. If set, only k-line data after that time will be returned.
//Time period of K line, default to 1. You can choose between 1, 5, 15, 30, 60, 120, 240, 360, 720, 1440, 4320, 10080
acx.getKLineWithPendingTrades({period:5}).then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Function will return the OHLC of the market which you have defined when you create the acx object if you haven't specified the market parameter.

acx.getKLineWithPendingTrades().then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Get server current time

Get server current time, in seconds since Unix epoch.

acx.getServerTimestamp().then(data => {
    console.log(data)
});

Get your cryptocurrency withdraws

parametertyperequired?description
currencyStringOptionalcurrency value(contains btc, aud, bch, eth, hsr, fuel, ubtc, eet, dash).
limitIntegeroptionalSet result limit.
stateStringoptionalFilter deposits by state.

Function will return your recent cryptocurrency withdraws if limit not set.

acx.getWithdraws().then(data=>{
    console.log(data)
}).catch(e => { console.error(e); });

Set more parameters to get cryptocurrency withdraws

acx.getWithdraws({currency: 'aud'}).then(data=>{
    console.log(data)
}).catch(e => { console.error(e); });

acx.getWithdraws({currency: 'aud', state: 'accepted', limit: 10}).then(data=>{
    console.log(data)
}).catch(e => { console.error(e); });

Get your cryptocurrency withdraw by id

parametertyperequired?description
idStringRequiredWithdrawal id
acx.getWithdrawById('25').then(data => {
    console.log(data)
}).catch(e => { console.error(e); });

Create a withdraw

parametertyperequired?description
currencyStringOptionalThe currency of withdrawal. Only btc is accepted. Default to 'btc'
sumBigDecimalRequiredSum amount for withdrawal.
addressStringRequiredCrypto-currency address. Now only bitcoin address.
feeBigDecimaloptionalMiner fee. Fee rate from 0.0001 to 0.001 /Kb.
acx.createWithdraw({sum:0.001, address: <'Crypto-currency address'>}).then(data => { 
    console.log(data)
}).catch(e => { console.error(e); });

WebSocket Usage

Initialise WebSocket

acx.initWebSorket();

Trades WebSocket

acx.onTradeChanged((data) => {
    console.log(data);
});

Orderbook WebSocket

acx.onOrderbookChanged(['btcaud','ethaud'], (data) => {
    console.log(data);
}, 10);

Authors

  • Sean Fang - Initial work
  • Shi Yan - Improvement

License

This project is licensed under the MIT License

1.3.9

6 years ago

1.3.8

6 years ago

1.3.7

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

1.0.0

7 years ago