BittrexJS
A 'strong typed' Bittrex API client written in typescript.
Typed
All methods have typed request parameters and typed responses using interfaces. Even when using the library in javascript, modern IDE's should be able to provide hints and warnings using the accompanied type files.
How to use
Install
npm install bittrexjs
Example
let BittrexClient = Client; let bittrex = ; // using promisesbittrex; // using awaitasync { let response = await client; console;}
Result:
success: true message: '' result: O: 007079 H: 007079 L: 007079 C: 007079 V: 49016782 T: '2017-09-11T19:20:00' BV: 346989793
Methods
Client.authenticate(apiCredentials: ApiCredentials)
This method authenticates your client so you can reach account specific endpoints.
Store your api keys wisely!
Example
let client = ; client;
Request Methods
All request methods return a promise with a BittrexResponse.
interface BittrexResponse<T> result: T success: boolean message: string
BittrexResponse.result contains the actual payload.
Client.getMarkets()
Retrieve all markets.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
none |
Returns
Promise<BittrexResponse<Market[]>>
Example
client;
Result:
MarketCurrency: 'RADS' BaseCurrency: 'BTC' MarketCurrencyLong: 'Radium' BaseCurrencyLong: 'Bitcoin' MinTradeSize: 1e-8 MarketName: 'BTC-RADS' IsActive: true Created: '2016-01-26T23:22:16.193' Notice: null IsSponsored: null LogoUrl: 'https://bittrexblobstorage.blob.core.windows.net/public/259f6efd-9b21-43cf-9c6b-8f67b94ca092.png' ...
Client.getCurrencies()
Retrieve all currencies.
Parameters
Name | Type | Required | Description |
---|---|---|---|
none |
Returns
Promise<BittrexResponse<Currency[]>>
Example
client;
Result:
Currency: 'XRP' CurrencyLong: 'Ripple' MinConfirmation: 10 TxFee: 002 IsActive: true CoinType: 'RIPPLE' BaseAddress: 'rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy' Notice: null ...
Client.getMarketTicker(market: string)
Retrieve Highest Bid
, Lowest Ask
and Price of Latest Trade
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | yes | e.g. BTC-ETH |
Returns
Promise<BittrexResponse<MarketTick>>
Example
let response = await client;let marketTick = responseresult; console;
Result:
Bid: 00707 Ask: 00709 Last: 00707
Client.getMarketCandles(market: string, tickInterval: TickInterval = 'FiveMin')
Retrieve OHLCV and BV (Open, High, Low, Close, Volume, Base Volume)
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | yes | e.g. BTC-ETH |
tickInterval | string (TickInterval) | no (defaults to FiveMin ) |
options: OneMin, FiveMin, ThirtyMin, hour, day |
Returns
Promise<BittrexResponse<Candle[]>
Example
let response = await client;let marketCandles = responseresult; console;
Result:
O: 00799 H: 008 L: 007988 C: 008 V: 14809106807 T: '2017-09-01T20:08:00' BV: 1183406577 ...
Client.getLatestCandle(market: string, tickInterval: TickInterval = 'FiveMin')
Retrieve latest OHLCV and BV (Open, High, Low, Close, Volume, Base Volume)
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | yes | e.g. BTC-ETH |
tickInterval | string (TickInterval) | no (defaults to FiveMin ) |
options: OneMin, FiveMin, ThirtyMin, hour, day |
Returns
Promise<BittrexResponse<Candle[]>
Example
let response = await client;let marketCandles = responseresult; console;
Result:
O: 0070555 H: 007094 L: 007055001 C: 007094 V: 1222247964 T: '2017-09-11T18:30:00' BV: 086240266
Client.getMarketSummaries()
Retrieve a summary for each market
Parameters
Name | Type | Required | Description |
---|---|---|---|
none |
Returns
Promise<BittrexResponse<MarketSummary[]>>
Example
let response = await client;let marketSummaries = responseresult; console;
Result:
MarketName: 'BTC-MCO' High: 000223017 Low: 000205001 Volume: 1966836355223 Last: 000213 BaseVolume: 4169640078 TimeStamp: '2017-09-11T18:37:28.14' Bid: 000213001 Ask: 000214227 OpenBuyOrders: 1025 OpenSellOrders: 11446 PrevDay: 00020872 Created: '2017-07-02T00:37:16.957' ...
Client.getMarketSummary(market: string)
Retrieve a summary for each market
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | yes | e.g. BTC-ETH |
Returns
Promise<BittrexResponse<MarketSummary[]>>
Example
let response = await client;let marketSummaries = responseresult; console;
Result:
MarketName: 'BTC-ETH' High: 007115187 Low: 006982622 Volume: 4338909963617 Last: 0070699 BaseVolume: 305627414511 TimeStamp: '2017-09-11T18:39:54.32' Bid: 007059785 Ask: 0070699 OpenBuyOrders: 3569 OpenSellOrders: 13823 PrevDay: 007028021 Created: '2015-08-14T09:02:24.817'
Client.getOrderbook(market: string, orderBookType: OrderBookType = 'both')
Retrieve a summary for each market
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | yes | e.g. BTC-ETH |
orderBookType | string (OrderBookType) | no (defaults to both ) |
options: buy, sell, both |
Returns
Promise<BittrexResponse<OrderbookEntry[] | Orderbook>>
'both' returns an orderbook, 'sell' and 'buy' return only a list of quantity-rate pairs.
Example (complete Orderbook)
let response = await client;let orderbook = responseresult; console;
Result:
buy: Quantity: 01 Rate: 007059785 ... sell: Quantity: 19251093 Rate: 007068 ...
Example ('buy' orders)
let response = await client;let orderbookentries = responseresult; console;
Result:
Quantity: 021277316 Rate: 006993263 ...
Client.getMarketHistory(market: string)
Retrieve the latest ??? orders for a market
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | yes | e.g. BTC-ETH |
Returns
Promise<BittrexResponse<Trade[]>>
Example
let response = await client;let marketHistory = responseresult; console;
Result:
Id: 110938880 TimeStamp: '2017-09-11T18:43:29.427' Quantity: 145871041 Price: 007068 Total: 010310165 FillType: 'PARTIAL_FILL' OrderType: 'BUY' Id: 110938789 TimeStamp: '2017-09-11T18:43:10.893' Quantity: 05179118 Price: 007050705 Total: 003651643 FillType: 'FILL' OrderType: 'SELL' ...
Account methods
For the following methods the client needs to be authenticated using client.authenticate(apiCredentials)
Client.buyLimit(market: string, quantity: number, rate: number)
Place limit buy order
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | yes | e.g. BTC-ETH |
quantity | number | yes | e.g. 0.01 |
rate | number | yes | e.g. 0.07050705 |
Returns
Promise<BittrexResponse<OrderReference[]>>
Client.sellLimit(market: string, quantity: number, rate: number)
Place limit sell order
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | yes | e.g. BTC-ETH |
quantity | number | yes | e.g. 0.01 |
rate | number | yes | e.g. 0.07050705 |
Returns
Promise<BittrexResponse<OrderReference[]>>
Client.cancel(orderId: string)
Cancel an order
Parameters
Name | Type | Required | Description |
---|---|---|---|
orderId | number | yes | e.g. 110938880 |
Returns
Promise<BittrexResponse<OrderReference[]>>
Client.getOpenOrders(market?: string)
Get all open orders for all markets, or for a single market
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | no | e.g. BTC-ETH |
Returns
Promise<BittrexResponse<OpenOrder[]>>
Client.getBalances()
Get all your balances
Parameters
Name | Type | Required | Description |
---|---|---|---|
none |
Returns
Promise<BittrexResponse<Balance[]>>
Client.getBalance(currency: string)
Get your balance for a single currency
Parameters
Name | Type | Required | Description |
---|---|---|---|
currency | string | yes | e.g. BTC |
Returns
Promise<BittrexResponse<Balance>>
Client.getWithdrawalHistory(currency?: string)
Get all withdrawals or all withdrawals for a single currency
Parameters
Name | Type | Required | Description |
---|---|---|---|
currency | string | no | e.g. BTC |
Returns
Promise<BittrexResponse<Withdrawal[]>>
Client.getWithdrawalHistory(currency?: string)
Get all withdrawals or all withdrawals for a single currency
Parameters
Name | Type | Required | Description |
---|---|---|---|
currency | string | no | e.g. BTC |
Returns
Promise<BittrexResponse<Withdrawal[]>>
Client.getDepositAddress(currency: string)
Get a deposit address for a currency
Parameters
Name | Type | Required | Description |
---|---|---|---|
currency | string | yes | e.g. BTC |
Returns
Promise<BittrexResponse<DepositAddress>>
Client.getDepositHistory(currency?: string)
Get your deposit history for all currencies or for one currency
Parameters
Name | Type | Required | Description |
---|---|---|---|
currency | string | no | e.g. BTC |
Returns
Promise<BittrexResponse<Deposit[]>>
Client.getOrderHistory(market?: string)
Get your order history for all markets or for one market
Parameters
Name | Type | Required | Description |
---|---|---|---|
market | string | no | e.g. BTC-ETH |
Returns
Promise<BittrexResponse<Order[]>>
Client.getOrder(orderId: string)
Get an order by id
Parameters
Name | Type | Required | Description |
---|---|---|---|
orderId | string | yes | e.g. 12412412 |
Returns
Promise<BittrexResponse<OrderSingle[]>>
Client.withdraw(currency: string, quantity: number, address: string, paymentid?: string)
Withdraw
Parameters
Name | Type | Required | Description |
---|---|---|---|
currency | string | yes | e.g. BTC |
quantity | number | yes | e.g. 0.5 |
address | string | yes | |
paymentid | string | no | An optional description to identify your payment |
Returns
Promise<BittrexResponse<OrderSingle[]>>
Contributing:
git clone https://github.com/stijnbuurman/BittrexJS.gitcd BittrexJSgit checkout -b myfeature masternpm installgulp
Roadmap
- Implement Bittrex WebSockets API
- Implement Bittrex API v2
- Finalize documentation - add examples for authenticated methods
- Finalize documentation - add examples for error catching
- Add 'live build' tool
- Remove inconsistencies
- Split client in 'simple' and 'raw'
- Add tests