npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

poloniex-public-client

v1.0.2

Published

A client Poloniex's public API.

Downloads

2

Readme

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'
         *   },
         *   ...
         * ]
         */
     });