poloniex-public-client

1.0.2 • Public • Published

Poloniex Public Client

Github: github.com/hudson155/poloniex-public-client NPM: npmjs.com/package/poloniex-public-client

Poloniex Public Client is a Javascript client for Poloniex's public API. It has request throttling built-in so that you don't exceed Poloniex's 6 request per second limit. This client requires no authentication.

Installation and Usage

Install it:

npm install --save poloniex-public-client

Use it:

// Dependencies
const moment = require('moment');
const PoloniexPublicClient = require('poloniex-public-client');

// Instantiate the client
const client = new PoloniexPublicClient();

// Options
const currencyPair = 'BTC_ETH';
const period = 300; // seconds
const startDate = moment().subtract(1, 'week').toDate();

// Make the call
client.returnChartData(currencyPair, period, startDate)
    .then(handleChartData);

// Handle the response
function handleChartData (chartData) {
    /* [
     *   {
     *     date: 1405699200,
     *     high: 0.0045388,
     *     low: 0.00403001,
     *     open: 0.00404545,
     *     close: 0.00427592,
     *     volume: 44.11655644,
     *     quoteVolume: 10259.29079097,
     *     weightedAverage: 0.00430015,
     *   },
     *   ...
     * ]
     */
}

Methods

return24hVolume()

Returns the 24-hour volume for all markets, plus totals for primary currencies.

Since

1.0.0

Arguments [none]

Example

const PoloniexPublicClient require('poloniex-public-client');
const client = new PoloniexPublicClient();

client.return24hVolume()
    .then(response => {
        /* {
         *   BTC_LTC: {
         *     BTC: 2.23248854,
         *     LTC: 87.10381314,
         *   },
         *   BTC_NXT:{
         *     BTC: 0.981616,
         *     NXT: 14145,
         *   },
         *   ...
         *   totalBTC: 81.89657704,
         *   totalLTC: 78.52083806,
         * }
         */
     });

returnChartData(currencyPair, period, startDate, endDate = new Date())

Returns candlestick chart data.

Since

1.0.0

Arguments

  • currencyPair (String): The currency pair to return data for.
  • period (Number): Candlestick period in seconds. Valid values: 300, 900, 1800, 7200, 14400, 86400.
  • startDate (Date-like): The start data for the period. This can be no more than 1 year ago. Must be ingestible by Moment.js.
  • endDate (Date-like, optional): The end date for the period. This must be after startDate, and not after now. Omitting this argument defaults it to now.

Example

const PoloniexPublicClient require('poloniex-public-client');
const client = new PoloniexPublicClient();

client.returnChartData('BTC_XMR', 14400, 14056992000000)
    .then(response => {
        /* {
         *   BTC_LTC: {
         *     BTC: 2.23248854,
         *     LTC: 87.10381314,
         *   },
         *   BTC_NXT:{
         *     BTC: 0.981616,
         *     NXT: 14145,
         *   },
         *   ...
         *   totalBTC: 81.89657704,
         *   totalLTC: 78.52083806,
         * }
         */
     });

returnCurrencies()

Returns information about currencies.

Since

1.0.0

Arguments [none]

Example

const PoloniexPublicClient require('poloniex-public-client');
const client = new PoloniexPublicClient();

client.returnCurrencies()
    .then(response => {
        /* {
         *   1CR: {
         *     maxDailyWithdrawal: 10000,
         *     txFee: 0.01,
         *     minConf: 3,
         *     disabled: 0
         *   },
         *   ABY: {
         *     maxDailyWithdrawal: 10000000,
         *     txFee: 0.01,
         *     minConf: 8,
         *     disabled: 0
         *   }, 
         *   ...
         * }
         */
     });

returnLoanOrders(currency)

Returns the list of loan offers and demands for a given currency.

Since

1.0.0

Arguments

  • currency (String): The currency to return data for.

Example

const PoloniexPublicClient require('poloniex-public-client');
const client = new PoloniexPublicClient();

client.returnLoanOrders()
    .then(response => {
        /* {
         *   offers: [
         *     {
         *       rate: '0.00200000',
         *       amount: '64.66305732',
         *       rangeMin: 2,
         *       rangeMax: 8
         *     }, 
         *     ...
         *   ],
         *   demands: [
         *     {
         *       rate: '0.00170000',
         *       amount: '26.54848841',
         *       rangeMin: 2,
         *       rangeMax: 2
         *     },
         *     ...
         *   ]
         * }
         */
     });

returnOrderBook(currencyPair, depth = 10)

Returns the order book for a given market, as well as a sequence number for use with the Push API and an indicator specifying whether the market is frozen. You may set currencyPair to "all" to get the order books of all markets.

Since

1.0.0

Arguments

  • currencyPair (String): The currency pair to return data for, or "all".
  • depth (Number, optional): The number of entries to retrieve. Omitting this argument defaults it to 10.

Example

const PoloniexPublicClient require('poloniex-public-client');
const client = new PoloniexPublicClient();

client.returnOrderBook('all')
    .then(response => {
        /* {
         *   BTC_NXT: {
         *     asks: [
         *       [0.00007600, 1164],
         *       [0.00007620, 1300],
         *       ...
         *     ],
         *     bids: [ 
         *       [0.00006901, 200],
         *       [0.00006900, 408],
         *       ...
         *     ],
         *     isFrozen: 0,
         *     seq: 149
         *   },
         *   ...
         * }
         */
     });
const PoloniexPublicClient require('poloniex-public-client');
const client = new PoloniexPublicClient();

client.returnOrderBook('BTC_NXT', 1)
    .then(response => {
        /* {
         *   asks: [
         *     [0.00007600, 1164],
         *   ], 
         *   bids: [
         *     [0.00006901, 200],
         *   ],
         *   isFrozen: 0,
         *   seq: 18849
         * }
         */
     });

returnTicker()

Returns the ticker for all markets.

Since

1.0.0

Arguments [none]

Example

const PoloniexPublicClient require('poloniex-public-client');
const client = new PoloniexPublicClient();

client.returnTicker()
    .then(response => {
        /* {
         *   BTC_LTC: {
         *     last: '0.0251',
         *     lowestAsk: '0.02589999',
         *     highestBid: '0.0251',
         *     percentChange: '0.02390438',
         *     baseVolume: '6.16485315',
         *     quoteVolume: '245.82513926'
         *   },
         *   BTC_NXT: {
         *     last: '0.00005730',
         *     lowestAsk: '0.00005710',
         *     highestBid: '0.00004903',
         *     percentChange: '0.16701570',
         *     baseVolume: '0.45347489',
         *     quoteVolume: '9094'
         *   },
         *   ...
         * }
         */
     });

returnTradeHistory(currencyPair, startDate, endDate = new Date())

Returns up to 50,000 trades in the specified date range.

Since

1.0.0

Arguments

  • currencyPair (String): The currency pair to return data for.
  • startDate (Date-like): The start data for the period. This can be no more than 1 year ago. Must be ingestible by Moment.js.
  • endDate (Date-like, optional): The end date for the period. This must be after startDate, and not after now. Omitting this argument defaults it to now.

Example

const PoloniexPublicClient require('poloniex-public-client');
const client = new PoloniexPublicClient();

client.returnTradeHistory()
    .then(response => {
        /* [
         *   {
         *     date: '2014-02-10 04:23:23',
         *     type: 'buy',
         *     rate: '0.00007600',
         *     amount: '140',
         *     total: '0.01064'
         *   },
         *   {
         *     date: '2014-02-10 01:19:37',
         *     type: 'buy',
         *     rate: '0.00007600',
         *     amount: '655',
         *     total: '0.04978'
         *   },
         *   ...
         * ]
         */
     });

Readme

Keywords

none

Package Sidebar

Install

npm i poloniex-public-client

Weekly Downloads

1

Version

1.0.2

License

ISC

Last publish

Collaborators

  • hudson155