SkillAgentSearch skills...

BittrexRx

BittrexRx is a rxjs node wrapper for the Bittrex Api

Install / Use

/learn @harry-sm/BittrexRx
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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.


npm version npm downloads Build Status Renovate badge David


My Other API Clients

Basic Usage

npm install bittrex-rx --save

Include in your project

import {
    BittrexRxClient,
    OrderConditionalTypeValue,
    TickIntervalValue,
    TimeInEffectValue,
    MarketOrderValue,
    OrderTypeValue,
    FillTypeValue,
    Model,
    LogTypeValue
} from "bittrex-rx";

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

import "rxjs";

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

import {
    BittrexRxClient,
    OrderConditionalTypeValue,
    TickIntervalValue,
    TimeInEffectValue,
    MarketOrderValue,
    OrderTypeValue,
    FillTypeValue,
    Model,
    LogTypeValue
} from '<path to project>';

BittrexRx Settings

settings(settings: BittrexRxSettings)

Sets settings for BittrexRx methods behaviors.

Parameters

| Parameter | Type | Example | Description | | --------- | ----------------- | ---------------------------------------- | ---------------------------------------- | | settings | BittrexRxSettings | {<br /> baseUrl: 'https://bittrex.com/api/',<br /> logType: LogTypeValue.Debug,<br /> logWriter: console.log<br />} | baseUrl: This is the entry point use to connect to the API server.<br />logType: The type of logs that should be displayed.<br /><ul><li>Debug: writes all log messages.</li><li>Error: writes only error messages.</li><li>Warning: writes only warning messages.</li> <li>logWriter: The function that takes a single string argument and outputs the log message.</li></ul> |

Example

import {
    BittrexRxClient,
    OrderConditionalTypeValue,
    TickIntervalValue,
    TimeInEffectValue,
    MarketOrderValue,
    Model,
    LogTypeValue
} from "bittrex-rx";

bittrexRx.settings({
  logType: LogTypeValue.Warning,
  logWriter: console.log
});

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.apiCredentials("API_KEY", "API_SECRET");

Example

import {
    BittrexRxClient,
    OrderConditionalTypeValue,
    TickIntervalValue,
    TimeInEffectValue,
    MarketOrderValue,
    OrderTypeValue,
    FillTypeValue,
    Model,
    LogTypeValue
} from 'bittrex-rx';

let bittrexRx = new BittrexClient();

bittrexRx.apiCredentials("API_KEY", "API_SECRET");

bittrexRx.getMarkets()
    .subscribe(
        data => {
            data.forEach(market => {
                bittrexRx.getTicker(market.MarketName).subscribe(tickData => {
                    console.log(tickData);
                });
            });
        },
        err => {
            console.log('Error', err);
        },
        () => {
            console.log('Completed');
        });

Response

{
    Bid: 0.00000345,
    Ask: 0.00000347,
    Last: 0.00000349
}

Observable Extension

intervalTime(milliseconds: number)

The intervalTime operator returns an observable that emits some sequence of data at specified intervals.

Example

bittrexRx.getMarkets()
    .intervalTime(5000)
    .subscribe(
        data => {
            for (let market of data) {
                console.log(market);
            }
        });

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.getMarkets()
    .subscribe(
        data => {
            for (let market of data) {
                console.log(market);
            }
        });

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.getCurrencies()
    .subscribe(
        data => {
            for (let currency of data) {
                console.log(currency);
            }
        });

Response

[
    {
        Currency: 'LTC',
        CurrencyLong: 'Litecoin',
        MinConfirmation: 6,
        TxFee: 0.01,
        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.getTicker('BTC-LTC')
    .subscribe(
        data => {
            console.log(data);
        });

Response

{
    Bid: 0.00966006,
    Ask: 0.00967006,
    Last: 0.00966006
}

bittrexRx.getMarketSummaries()

Fetches the summary of each market available.

Parameters

| Parameter | Type | Example | | --------- | ---- | ------- | | none | - | - |

Return Type

Observable<Model.MarketSummary[]>

Example

bittrexRx.getMarketSummaries()
    .subscribe(
        data => {
            for (let marketSummary of data) {
                console.log(marketSummary);
            }
        });

Response

[
    {
        MarketName: 'BTC-LTC',
        High: 0.01023899,
        Low: 0.00966416,
        Volume: 79788.80702209,
        Last: 0.00970283,
        BaseVolume: 791.93512777,
        TimeStamp: '2017-10-26T01:52:30.430Z',
        Bid: 0.00970283,
        Ask: 0.00970683,
        OpenBuyOrders: 2143,
        OpenSellOrders: 12833,
        PrevDay: 0.01020636,
        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.getMarketSummary('BTC-LTC')
    .subscribe(
        data => {
            console.log(data);
        });

Response

{
    MarketName: 'BTC-LTC',
    High: 0.01023899,
    Low: 0.00966416,
    Volume: 79788.80702209,
    Last: 0.00970283,
    BaseVolume: 791.93512777,
    TimeStamp: '2017-10-26T01:52:30.430Z',
    Bid: 0.00970283,
    Ask: 0.00970683,
    OpenBuyOrders: 2143,
    OpenSellOrders: 12833,
    PrevDay: 0.01020636,
    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.getOrderBook('BTC-LTC')
    .subscribe(
        data => {
           for (let orderItem of data.buy) {
                console.log(orderItem);
            }
        });

Response

{
    buy: [
        { Quantity: 0.1, Rate: 0.07059785 },
        ...
    ],
    sell: [
        { Quantity: 1.9251093, Rate: 0.07068 },
        ...
    ]
}

bittrexRx.getBuyOrderBook(market: string)

Fetches buy orders from the order book for a specific market.

Parameters

| Parameter | Type |

View on GitHub
GitHub Stars16
CategoryDevelopment
Updated5y ago
Forks3

Languages

TypeScript

Security Score

80/100

Audited on Sep 4, 2020

No findings