BittrexRx
BittrexRx is an Reactive library that was built with TypeScript for the Bittrex API which runs on the node.js platform. I built this library because I couldn't find any other library that uses rxjs.
My Other API Clients
- CobinhoodRx (Typescript) - API client for the Cobinhood Exchange.
- BittrexRxSharp (C#)
Basic Usage
npm install bittrex-rx --save
Include in your project
;
Note: To gain access to rxjs operators such as
map()
,flatMap()
,filter()
, you will need to include rxjs in your project.
Install
npm install rxjs
Include in your project
;
Advance Usage
Fetch the project via git:
git clone https://github.com/harry-sm/BittrexRx.git
Install package dependencies:
npm install
Build Project
npm run build
Include in your project
;
BittrexRx Settings
settings(settings: BittrexRxSettings)
Sets settings for BittrexRx methods behaviors.
Parameters
Parameter | Type | Example | Description |
---|---|---|---|
settings | BittrexRxSettings | { baseUrl: 'https://bittrex.com/api/', logType: LogTypeValue.Debug, logWriter: console.log } |
baseUrl: This is the entry point use to connect to the API server. logType: The type of logs that should be displayed.
|
Example
; bittrexRx;
Api Credentials
Sign into your Bittrex account go to settings then API keys and add new key.
The API key has four access permissions they are:
- READ INFO - Grants access to read private trade data such as orders, transaction history, balances, etc...
- TRADE LIMIT - Grants access to limit order functions, which includes creating and canceling limit buy and sell orders.
- TRADE MARKET - Grants access to other order functions, which includes creating and canceling conditional buy and sell orders.
- WITHDRAW - Grants access to the withdraw function which allows for withdrawals to another address. (This function is not available via the public interface of this library.)
For first time use please set API permissions to READ INFO only.
bittrexRx;
Example
; let bittrexRx = ; bittrexRx; bittrexRx ;
Response
Bid: 000000345 Ask: 000000347 Last: 000000349
Observable Extension
intervalTime(milliseconds: number)
The intervalTime operator returns an observable that emits some sequence of data at specified intervals.
Example
bittrexRx ;
The example above fetches market data every 5 seconds.
Public API Method
bittrexRx.getMarkets()
Fetches a snapshot of all markets.
Parameters
Parameter | Type | Example |
---|---|---|
none | - | - |
Return Type
Observable<Model.Market[]>
Example
bittrexRx ;
Response
MarketCurrency: 'LTC' BaseCurrency: 'BTC' MarketCurrencyLong: 'Litecoin' BaseCurrencyLong: 'Bitcoin' MinTradeSize: 1e-8 MarketName: 'BTC-LTC' IsActive: true Created: '2014-02-13T05:00:00.000Z' Notice: null IsSponsored: null LogoUrl: 'https://bittrexblobstorage.blob.core.windows.net/public/6defbc41-582d-47a6-bb2e-d0fa88663524.png' ...
bittrexRx.getCurrencies()
Fetches all the market currencies.
Parameters
Parameter | Type | Example |
---|---|---|
none | - | - |
Return Type
Observable<Model.Currency[]>
Example
bittrexRx ;
Response
Currency: 'LTC' CurrencyLong: 'Litecoin' MinConfirmation: 6 TxFee: 001 IsActive: true CoinType: 'BITCOIN' BaseAddress: 'LhyLNfBkoKshT7R8Pce6vkB9T2cP2o84hx' Notice: null ...
bittrexRx.getTicker(market: string)
Fetches the Tick data which consists of the Bid, Ask and Latest Price the market was traded at.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'BTC-LTC' |
Return Type
Observable<Model.Ticker>
Example
bittrexRx ;
Response
Bid: 000966006 Ask: 000967006 Last: 000966006
bittrexRx.getMarketSummaries()
Fetches the summary of each market available.
Parameters
Parameter | Type | Example |
---|---|---|
none | - | - |
Return Type
Observable<Model.MarketSummary[]>
Example
bittrexRx ;
Response
MarketName: 'BTC-LTC' High: 001023899 Low: 000966416 Volume: 7978880702209 Last: 000970283 BaseVolume: 79193512777 TimeStamp: '2017-10-26T01:52:30.430Z' Bid: 000970283 Ask: 000970683 OpenBuyOrders: 2143 OpenSellOrders: 12833 PrevDay: 001020636 Created: '2014-02-13T05:00:00.000Z' ...
bittrexRx.getMarketSummary(market: string)
Fetches the summary of a specific market.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'BTC-LTC' |
Return Type
Observable<Model.MarketSummary>
Example
bittrexRx ;
Response
MarketName: 'BTC-LTC' High: 001023899 Low: 000966416 Volume: 7978880702209 Last: 000970283 BaseVolume: 79193512777 TimeStamp: '2017-10-26T01:52:30.430Z' Bid: 000970283 Ask: 000970683 OpenBuyOrders: 2143 OpenSellOrders: 12833 PrevDay: 001020636 Created: '2014-02-13T05:00:00.000Z'
bittrexRx.getOrderBook(market: string)
Fetches both buy and sell orders from the order book for a specific market.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'BTC-LTC' |
Return Type
Observable<Model.OrderBook>
Example
bittrexRx ;
Response
buy: Quantity: 01 Rate: 007059785 ... sell: Quantity: 19251093 Rate: 007068 ...
bittrexRx.getBuyOrderBook(market: string)
Fetches buy orders from the order book for a specific market.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'BTC-LTC' |
Return Type
Observable<Model.OrderBookOrderItem>
Example
bittrexRx ;
Response
Quantity: 01 Rate: 007059785 ...
bittrexRx.getSellOrderBook(market: string)
Fetches sell orders from the order book for a specific market.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'BTC-LTC' |
Return Type
Observable<Model.OrderBookOrderItem>
Example
bittrexRx ;
Response
Quantity: 19251093 Rate: 007068 ...
bittrexRx.getMarketHistory(market: string)
Fetches the latest transactions for a specific market.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'BTC-LTC' |
Return Type
Observable<Model.MarketHistory[]>
Example
bittrexRx ;
Response
Id: 85963164 TimeStamp: '2017-10-26T02:00:10.273Z' Quantity: 329091587 Price: 000973473 Total: 003203617 FillType: 'PARTIAL_FILL' OrderType: 'BUY' ...
bittrexRx.getCandles(market: string, tickIntervalType: TickIntervalValue)
Fetches the OHLC (Open, High, Low, Close) of a market for a given time period.
Note: This method relies on the v2 API of Bittrex. Very little is known about this version of the API and is subjected to change without warning!
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'USDT-BTC' |
tickIntervalType | TickIntervalValue | TickIntervalValue.oneMin, TickIntervalValue.fiveMin, ... |
Return Type
Observable<Model.Candle[]>
Example
bittrexRx ;
Response
O: 001149845 H: 00115379 L: 001149845 C: 00115379 V: 4698461375 T: '2017-10-16T03:56:00.000Z' BV: 05419376 ...
Account API Methods
bittrexRx.getBalances()
Fetches all your current currency balances.
Parameters
Parameter | Type | Example |
---|---|---|
none | - | - |
Return Type
Observable<Model.Balance[]>
Example
bittrexRx ;
Response
Currency: 'LTC' Balance: 0 Available: 0 Pending: 0 CryptoAddress: null ...
bittrexRx.getBalance(currency: string)
Fetches the current balance of a specific currency.
Parameters
Parameter | Type | Example |
---|---|---|
currency | string | 'LTC' |
Return Type
Observable<Model.Balance>
Example
bittrexRx ;
Response
Currency: 'LTC' Balance: 0 Available: 0 Pending: 0 CryptoAddress: null
bittrexRx.getDepositAddress(currency: string)
Fetches the deposit address of a specific currency.
Parameters
Parameter | Type | Example |
---|---|---|
currency | string | 'LTC' |
Return Type
Observable<Model.DepositAddress>
Example
bittrexRx ;
Response
Currency: 'LTC' Address: ''
bittrexRx.getOrder(uuid: string)
Fetches an order by a specific identifier.
Return Type
Observable<Model.Order>
Parameters
Parameter | Type | Example |
---|---|---|
uuid | string | '2968d0f9-2854-48e5-bbbf-18a2b7451140' |
Example
bittrexRx ;
Response
AccountId: null OrderUuid: 'dc1a6628-7e12-4817-aa16-b5e9860d116c' Exchange: 'BTC-XVG' Type: 'LIMIT_BUY' Quantity: 32622641509 QuantityRemaining: 0 Limit: 000000159 Reserved: 000051869 ReserveRemaining: 000051869 CommissionReserved: 000000129 CommissionReserveRemaining: 0 CommissionPaid: 000000129 Price: 000051869 PricePerUnit: 000000158 Opened: '2017-09-27T02:47:50.740Z' Closed: '2017-09-27T03:39:30.280Z' IsOpen: false Sentinel: 'Invalid Date' CancelInitiated: false ImmediateOrCancel: false IsConditional: false Condition: 'NONE' ConditionTarget: null
bittrexRx.getOrderHistory()
Fetches the total transaction history.
Parameters
Parameter | Type | Example |
---|---|---|
none | - | - |
Return Type
Observable<Model.OrderHistoryOrderItem[]>
Example
bittrexRx ;
Response
OrderUuid: 'dc1a6628-7e12-4817-aa16-b5e9860d116c' Exchange: 'BTC-XVG' TimeStamp: '2017-09-27T02:47:50.740Z' OrderType: 'LIMIT_BUY' Limit: 000000159 Quantity: 32622641509 QuantityRemaining: 0 Commission: 000000129 Price: 000051869 PricePerUnit: 000000158 IsConditional: false Condition: 'NONE' ConditionTarget: null ImmediateOrCancel: false Closed: '2017-09-27T03:39:30.280Z' ...
bittrexRx.getDepositHistory(currency: string)
Fetches the deposit records of the currency specified.
Parameters
Parameter | Type | Example |
---|---|---|
currency | string | 'LTC' |
Return Type
Observable<Model.Transaction[]>
Example
bittrexRx ;
Response
Id: 26972433 Amount: 002455098 Currency: 'BTC' Confirmations: 4 LastUpdated: '2017-08-16T22:13:47.783Z' TxId: '8aa448a50b06c0e1436e6e000132d721761e54cac365769ec1136a391df44bfc' CryptoAddress: '138TtdZkyMU8GMY8tzpZuc7xsqrb4CwrGE' ...
bittrexRx.getWithdrawalHistory(currency: string)
Fetches the withdrawal records of the currency specified.
Parameters
Parameter | Type | Example |
---|---|---|
currency | string | 'BTC' |
Return Type
Observable<Model.WithdrawalTransaction[]>
Example
bittrexRx ;
Response
PaymentUuid: "b14f86bb-b15b-4177-9779-5466eb3a0fbc" Currency: "BTC" Amount: 002039674 Address: "1Fo8nz1m4fBb7iDKWDghiA6YSEsg4HZJxD" Opened: "2017-08-18T04:40:44.737" Authorized: true PendingPayment: false TxCost: 0001 TxId: "38a3147f51b8c4798d1a5b3e2712bd7b7177fa99d6457af45a84e56664b6bbc6" Canceled: false InvalidAddress: false ...
Market API Methods
bittrexRx.setBuyOrder(market: string, quantity: number, rate: number)
Place buy limit order for a market pair at a rate and quantity specified.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'BTC-LTC' |
quantity | number | 0.05849296 |
rate | number | 0.00869720 |
Return Type
Observable<Model.OrderResult>
Example
bittrexRx ;
Response
uuid: '54a1cc8f-10dc-49de-bb52-f5d70b1c84ec'
bittrexRx.setSellOrder(market: string, quantity: number, rate: number)
Place sell limit order for a market pair at a rate and quantity specified.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'USDT-BTC' |
quantity | number | 0.0051 |
rate | number | 7000 |
Return Type
Observable<Model.OrderResult>
Example
bittrexRx ;
Response
uuid: '2968d0f9-2854-48e5-bbbf-18a2b7451140'
bittrexRx.getOpenOrders(market: string)
Fetch orders that has not been executed for specific market.
Parameters
Parameter | Type | Example |
---|---|---|
market | string | 'BTC-GNT' |
Return Type
Observable<Model.OpenOrder[]>
Example
bittrexRx ;
Response
Uuid: null OrderUuid: '9a6e6f63-de19-475a-ad81-c85129681253' Exchange: 'BTC-GNT' OrderType: 'LIMIT_BUY' Quantity: 1614487464 QuantityRemaining: 1614487464 Limit: 000003151 CommissionPaid: 0 Price: 0 PricePerUnit: null Opened: '2017-10-24T03:50:26.250Z' Closed: null CancelInitiated: false ImmediateOrCancel: false IsConditional: false Condition: 'NONE' ConditionTarget: null
bittrexRx.cancelOrder(uuid: string)
Cancel order returns null.
Parameters
Parameter | Type | Example |
---|---|---|
uuid | string | '2968d0f9-2854-48e5-bbbf-18a2b7451140' |
Return Type
Observable<void>
Example
bittrexRx ;
Response
null
bittrexRx.setConditionalBuyOrder(market: string, marketOrderType: MarketOrderValue, quantity: number, rate: number, timeInEffect: TimeInEffectValue, conditionType: OrderConditionalTypeValue, target: number)
Executes buy orders under the conditions specified.
Note: This method relies on the v2 API of Bittrex. Very little is known about this version of the API and is subjected to change without warning!
Parameter
Parameter | Type | Example | Description |
---|---|---|---|
market | string | 'BTC-ETH' | |
marketOrderType | MarketOrderValue | MarketOrderValue.LIMIT | LIMIT: The order will be executed at a specific price. |
quantity | number | 0.01162237 | - |
rate | number | 0.04377120 | - |
timeInEffect | TimeInEffectValue | TimeInEffectValue.IMMEDIATE_OR_CANCEL, TimeInEffectValue.GOOD_TIL_CANCELLED, TimeInEffectValue.FILL_OR_KILL |
IMMEDIATE_OR_CANCEL: The order must be executed immediately or else it is canceled. Partial fills are accepted . GOOD_TIL_CANCELLED:,The order is placed until the user cancels it. FILL_OR_KILL: The order must be completed in its entirety. The full quantity of the order at a fixed prices must be executed or canceled. |
conditionType | OrderConditionalTypeValue | OrderConditionalTypeValue.NONE, OrderConditionalTypeValue.GREATER_THAN, OrderConditionalTypeValue.LESS_THAN |
GREATER_THAN: The order will be executed if the price of the security is greater than the price specified in the target parameter. LESS_THAN: The order will be executed if the price of the security is less than the price specified in the target parameter. |
target | number | 0.0 | - |
Return Type
Observable<Model.ConditionalOrder>
Example
bittrexRx ;
Response
OrderId: 'ac983afd-6852-478e-8415-d6e30615ea9c' MarketName: 'BTC-ETH' MarketCurrency: 'ETH' BuyOrSell: 'Buy' OrderType: 'LIMIT' Quantity: 001162237 Rate: 00437712
bittrexRx.setConditionalSellOrder(market: string, marketOrderType: MarketOrderValue, quantity: number, rate: number, timeInEffect: TimeInEffectValue, conditionType: OrderConditionalTypeValue, target: number)
Executes sell orders under the conditions specified.
Note: This method relies on the v2 API of Bittrex. Very little is known about this version of the API and is subjected to change without warning!
Parameter
Parameter | Type | Example | Description |
---|---|---|---|
market | string | 'USDT-ETH' | |
marketOrderType | MarketOrderValue | MarketOrderValue.LIMIT | LIMIT: The order will be executed at a specific price. |
quantity | number | 0.01574783 | - |
rate | number | 400 | - |
timeInEffect | TimeInEffectValue | TimeInEffectValue.IMMEDIATE_OR_CANCEL, TimeInEffectValue.GOOD_TIL_CANCELLED, TimeInEffectValue.FILL_OR_KILL |
IMMEDIATE_OR_CANCEL: The order must be executed immediately or else it is canceled. Partial fills are accepted . GOOD_TIL_CANCELLED:,The order is placed until the user cancels it. FILL_OR_KILL: The order must be completed in its entirety. The full quantity of the order at a fixed prices must be executed or canceled. |
conditionType | OrderConditionalTypeValue | OrderConditionalTypeValue.NONE, OrderConditionalTypeValue.GREATER_THAN, OrderConditionalTypeValue.LESS_THAN |
GREATER_THAN: The order will be executed if the price of the security is greater than the price specified in the target parameter. LESS_THAN: The order will be executed if the price of the security is less than the price specified in the target parameter. |
target | number | 0.0 | - |
Return Type
Observable<Model.ConditionalOrder>
Example
bittrexRx ;
Response
OrderId: 'b27a6b86-bae6-4b04-be2d-6726e717e53e' MarketName: 'USDT-ETH' MarketCurrency: 'ETH' BuyOrSell: 'Sell' OrderType: 'LIMIT' Quantity: 001574783 Rate: 400
customRequest(url: string, queryOptions: Object, useCredentials: Boolean)
This method is not dependent on the API version and allows for the sending of custom requests.
Parameters
Parameter | Type | Example | Description |
---|---|---|---|
url | string | https://bittrex.com/api/v1.1/public/getmarketsummary | API endpoint. |
queryOptions | Object | { market: 'BTC-LTC' } | Query string parameters. |
useCredentials | Boolean | false | Specify whether the API credentials should be enabled or not. |
Return Type
Observable<any>
Example
bittrexRx ;
Response
MarketName: 'BTC-LTC' High: 000908 Low: 00076 Volume: 29175848361243 Last: 00084773 BaseVolume: 246480235543 TimeStamp: '2017-11-08T00:32:02.203' Bid: 000846202 Ask: 00084773 OpenBuyOrders: 2964 OpenSellOrders: 13074 PrevDay: 000775 Created: '2014-02-13T00:00:00'
Web Socket
bittrexRx.Socket.summaryState()
Connect to a live stream of market summary data.
Parameters
Parameter | Type | Example |
---|---|---|
none | - | - |
Return Type
Observable<Model.SummaryStateDelta>
Example
bittrexRxSocket ;
Response
Nounce: 51705 Deltas: MarketName: 'USDT-BTC' High: 6002 Low: 541036691866 Volume: 989962086304 Last: 56939 BaseVolume: 5648341089562297 TimeStamp: '2017-10-23T18:25:14.817Z' Bid: 5689 Ask: 56939 OpenBuyOrders: 7611 OpenSellOrders: 3541 PrevDay: 5850 Created: '2015-12-11T06:31:40.633Z' ...
bittrexRx.Socket.exchangeState(market: string[])
Connect to a live stream of specific market data. The data consists of the order books and market history.
Parameters
Parameter | Type | Example |
---|---|---|
market | string[] | ['BTC-L TC'] |
Return Type
Observable<Model.OrderBookStream>
Example
bittrexRxSocket ;
Response
MarketName: 'BTC-ETH' Nounce: 40393 Buys: Type: 1 Rate: 0053516 Quantity: 0 Type: 1 Rate: 005344106 Quantity: 0 Type: 2 Rate: 005188199 Quantity: 004339557 Type: 2 Rate: 005170671 Quantity: 004354268 Type: 2 Rate: 005153143 Quantity: 004369078 Type: 2 Rate: 005135616 Quantity: 00438399 Type: 2 Rate: 005118088 Quantity: 004399003 Type: 2 Rate: 00510056 Quantity: 00441412 Sells: Type: 2 Rate: 005382 Quantity: 1018061112 Type: 2 Rate: 005434562 Quantity: 483608199 Type: 0 Rate: 005450161 Quantity: 871091193 Type: 1 Rate: 005450262 Quantity: 0 Fills: OrderType: 'BUY' Rate: 005382 Quantity: 042158507 TimeStamp: '2017-10-24T20:16:12.213Z'
bittrexRx.Socket.close()
Closes socket connection.
Parameters
Parameter | Type | Example |
---|---|---|
none | - | - |
Return Type
Void
Example
bittrexRxSocket;
Websockets ServiceHandlers
Example
bittrexRxSocketStatus{ console;} bittrexRxSocketStatus{ console;} bittrexRxSocketStatus{ console;} bittrexRxSocketStatus{ console;} bittrexRxSocketStatus{ console} bittrexRxSocketStatus{ console;} bittrexRxSocketStatus{ console; return true;}