2.0.2 • Published 5 years ago

node-tidex-api v2.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

node-tidex-api

Node.js module for Tidex exchange api integration (docs).

Installation

yarn add node-tidex-api

Getting started

Import the module and create a new api instance. Passing api keys is optional only if you don't plan on doing authenticated calls.

import Tidex from 'node-tidex-api';

const api = new Tidex();

// Authenticated client, can make signed calls
const api2 = Tidex({
  apiKey: 'xxx',
  apiSecret: 'xxx',
});

const markets = await api.getMarkets();

Table of Contents

Public REST Endpoints

getMarkets

Returns available markets. Module will serve local cache with markets after first fetch.

ParamTypeRequiredDefaultDescription
forceBooleanfalsefalseUpdate local cache or not

Example:

console.log(await api.getMarkets());
[ 
    Market {
        base: 'LTC',
        quote: 'BTC',
        precision: 8,
        fee: 0.1,
        minPrice: 1e-8,
        minAmount: 0.001,
        maxPrice: 3,
        maxAmount: 1000000,
        minTotal: 0.0001 
    },
    Market {
        base: 'ETH',
        quote: 'BTC',
        precision: 8,
        fee: 0.1,
        minPrice: 1e-8,
        minAmount: 0.001,
        maxPrice: 3,
        maxAmount: 1000000,
        minTotal: 0.0001 
    },
    Market {
        base: 'DASH',
        quote: 'BTC',
        precision: 8,
        fee: 0.1,
        minPrice: 1e-8,
        minAmount: 0.001,
        maxPrice: 3,
        maxAmount: 1000000,
        minTotal: 0.0001 
    },
    ...
]

getTickers

Returns tickers for given markets.

ParamTypeRequiredDefault
symbolsArray\<String>falseAll

Example:

console.log(await api.getTickers(['ETH/BTC', 'BTC/USDT']));
[ 
    Ticker {
        base: 'ETH',
        quote: 'BTC',
        ask: 0.0342154,
        bid: 0.03387898,
        last: 0.0342154,
        high: 0.03486638,
        low: 0.03200994,
        avg: 0.03343816,
        baseVolume: 41.00653576,
        quoteVolume: 1.3988951666331848 
     },
     Ticker {
        base: 'BTC',
        quote: 'USDT',
        ask: 6605.53606,
        bid: 6490.00000001,
        last: 6490,
        high: 6612.14821,
        low: 6490,
        avg: 6551.074105,
        baseVolume: 0.0164071,
        quoteVolume: 106.519590715291
    }
 ]

getOrderBooks

Returns orderbooks for given markets.

ParamTypeRequiredDefault
symbolsArray\<String>falseAll
limitNumberfalse150

Example:

console.log(await api.getOrderBooks({limit: 2, symbols: ['ETH/BTC', 'BTC/USDT']}));
[ 
    OrderBook {
        base: 'ETH',
        quote: 'BTC',
        asks: [
            Ask { price: 0.0344287, amount: 0.00416927 },
            Ask { price: 0.03442871, amount: 0.36306581 } 
        ],
        bids: [
            Bid { price: 0.03429006, amount: 19.8 },
            Bid { price: 0.03428996, amount: 2.50125062 } 
        ] 
    }, OrderBook {
        base: 'BTC',
        quote: 'USDT',
        asks: [ 
            Ask { price: 6635.13857705, amount: 0.00108004 },
            Ask { price: 6648.42847346, amount: 0.030436 } 
        ],
        bids: [ 
            Bid { price: 6550.15, amount: 0.00013106 },
            Bid { price: 6490.00000001, amount: 0.1001001 } 
        ] 
    } 
]

getTrades

Returns last trades for given markets.

ParamTypeRequiredDefault
symbolsArray\<String>falseAll
limitNumberfalse150

Example:

console.log(await api.getTrades({limit: 2, symbols: ['ETH/BTC', 'BTC/USDT']}));
[ 
    Trades {
        base: 'ETH',
        quote: 'BTC',
        trades: [ 
            Trade {
                operation: 'buy',
                amount: 0.16506953,
                price: 0.0342154,
                timestamp: 1538585177,
                orderId: undefined,
                tradeId: 25109568 
            },
            Trade {
                operation: 'buy',
                amount: 0.04733047,
                price: 0.03408376,
                timestamp: 1538585177,
                orderId: undefined,
                tradeId: 25109567 
            } 
        ] 
    },
    Trades {
        base: 'BTC',
        quote: 'USDT',
        trades: [ 
            Trade {
                operation: 'sell',
                amount: 0.0161,
                price: 6490,
                timestamp: 1538536995,
                orderId: undefined,
                tradeId: 25087685 
            },
            Trade {
                operation: 'sell',
                amount: 0.0003071,
                price: 6612.14821,
                timestamp: 1538510726,
                orderId: undefined,
                tradeId: 25076489 
            } 
        ]
    } 
 ]

Authenticated REST Endpoints

getAccountInfo

Returns information about account.

Example:

console.log(await api2.getAccountInfo());
AccountInfo {
    balances: [ 
        Balance { 
            currency: 'ETH', 
            free: 0, 
            used: 0, 
            total: 0.04003445195115 
        } 
    ],
    openOrdersCount: 0,
    rights: { 
        info: true, 
        trade: true, 
        withdraw: false 
    } 
}

getAccountInfoExtended

Returns information about account with more detail balances info.

Example:

console.log(await api2.getAccountInfoExtended());
AccountInfo {
    balances: [ 
        Balance {
            currency: 'ETH',
            free: 0.04003445195115,
            used: 0,
            total: 0.04003445195115 
        } 
    ],
    openOrdersCount: 0,
    rights: { 
        info: true, 
        trade: true, 
        withdraw: false 
    } 
}

limitOrder

Create limit order.

ParamTypeRequiredDescription
symbolStringtrue
priceNumbertrue
amountNumbertrue
operationStringtrue"buy" or "sell"

Example:

console.log(await api2.limitOrder('REM/ETH', 0.00003069, 30, "buy"));
Order {
    id: 235717815,
    base: 'REM',
    quote: 'ETH',
    operation: 'buy',
    amount: 40,
    remain: 40,
    price: 0.00003069,
    created: 1538647492,
    status: 'active'
}

getActiveOrders

Returns open orders for account.

ParamTypeRequiredDefault
symbolStringfalseAll

Example:

console.log(await api2.getActiveOrders('REM/ETH'));
[ 
    Order {
        id: 235717815,
        base: 'REM',
        quote: 'ETH',
        operation: 'buy',
        amount: 40,
        remain: 40,
        price: 0.00003069,
        created: 1538647493,
        status: 'active'
    } 
]

getTradeHistory

Returns account history of trades.

ParamTypeRequiredDescription
countStringfalsetrades limit
fromIdNumberfalsevalue is trade id
symbolStringfalse

Example:

console.log(await api2.getTradeHistory({ symbol: 'REM/ETH' }))
[
    {
        base: "REM", 
        quote: "ETH", 
        trades: [
            {amount: 100, operation: "buy", orderId: 234224913, price: 0.00003112, timestamp: 1538405421, tradeId: 25031255}, 
            {amount: 35, operation: "buy", orderId: 234263388, price: 0.00003132, timestamp: 1538411344, tradeId: 25033988}, 
            {amount: 134.865, operation: "sell", orderId: 234263509, price: 0.00003149, timestamp: 1538493508, tradeId: 25070252}
        ]
    }
]

getOrder

Returns order information.

ParamTypeRequired
orderIdNumbertrue

Example:

console.log(await api2.getOrder(234263388));
Order {
    id: 234263388,
    base: 'REM',
    quote: 'ETH',
    operation: 'buy',
    amount: 35,
    remain: 0,
    price: 0.00003132,
    created: 1538411344,
    status: 'closed' 
}

cancelOrder

Order cancellation.

ParamTypeRequired
orderIdNumbertrue

Example:

console.log(await api2.cancelOrder(235717815));

Method returns array of Balance objects updated after order cancellation.

[ 
    Balance { 
        currency: 'ETH', 
        free: 0,
        used: 0,
        total: 0.04003445195115 
    }
]
2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago