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

@warren-bank/node-poloniex-api

v2.1.5

Published

poloniex.com API client library for Node.js

Downloads

23

Readme

Node.js Poloniex API

Node.js Client Library for the Poloniex (poloniex.com) API

This is an asynchronous Promise-based Node.js client for the poloniex.com API.

Installation:

npm install --save @warren-bank/node-poloniex-api

Usage:

  • class constructor:
    • input: api_key (required), api_secret (required), config (optional: {agent, timeout})
  • api() method:
    • input: method (required), params (varies by method) where: method is one of the following values (as specified in the official API docs ):
      • public:
        • 'returnTicker', {}
        • 'return24hVolume', {}
        • 'returnOrderBook', {currencyPair, depth}
        • 'returnTradeHistory', {currencyPair, start, end}
        • 'returnChartData', {currencyPair, period, start, end}
        • 'returnCurrencies', {}
        • 'returnLoanOrders', {currency, limit}
      • private:
        • 'returnBalances', {}
        • 'returnCompleteBalances', {account}
        • 'returnDepositAddresses', {}
        • 'generateNewAddress', {currency}
        • 'returnDepositsWithdrawals', {start, end}
        • 'returnOpenOrders', {currencyPair}
        • 'returnMyTradeHistory', {currencyPair, start, end}
        • 'returnOrderTrades', {orderNumber}
        • 'buy', {currencyPair, rate, amount, fillOrKill, immediateOrCancel, postOnly}
        • 'sell', {currencyPair, rate, amount, fillOrKill, immediateOrCancel, postOnly}
        • 'cancelOrder', {orderNumber}
        • 'moveOrder', {orderNumber, rate, amount, immediateOrCancel, postOnly}
        • 'withdraw', {currency, amount, address}
        • 'returnFeeInfo', {}
        • 'returnAvailableAccountBalances', {account}
        • 'returnTradableBalances', {}
        • 'transferBalance', {currency, amount, fromAccount, toAccount}
        • 'returnMarginAccountSummary', {}
        • 'marginBuy', {currencyPair, rate, amount, lendingRate}
        • 'marginSell', {currencyPair, rate, amount, lendingRate}
        • 'getMarginPosition', {currencyPair}
        • 'closeMarginPosition', {currencyPair}
        • 'createLoanOffer', {currency, amount, duration, autoRenew, lendingRate}
        • 'cancelLoanOffer', {orderNumber}
        • 'returnOpenLoanOffers', {}
        • 'returnActiveLoans', {}
        • 'returnLendingHistory', {start, end, limit}
        • 'toggleAutoRenew', {orderNumber}
    • output: Promise
  • helper library methods:
    • helper.get_ticker(currencyPair)
      • input: currencyPair
      • output: Promise
      • behavior:
        • call api('returnTicker')
        • return value in response hash table for the key: currencyPair
    • helper.get_trading_pairs()
      • input:
      • output: Promise
      • behavior:
        • call api('returnTicker')
        • return array of keys in response hash table
    • helper.get_total_balance(currency)
      • input: currency
      • output: Promise
      • behavior:
        • call api('returnBalances')
        • call api('returnTicker')
        • for each coin having a balance:
          • add to sum: value of coin in currency, based on its current ticker price
          • call api('returnOpenOrders', {currencyPair})
          • for each open order:
            • add to sum: the value of the order in currency
        • return sum
    • helper.get_total_btc_balance()
      • input:
      • output: Promise
      • behavior:
        • call helper.get_total_balance('BTC')
    • helper.get_total_eth_balance()
      • input:
      • output: Promise
      • behavior:
        • call helper.get_total_balance('ETH')

Example:

const PoloniexClient = require('@warren-bank/node-poloniex-api')
const poloniex = new PoloniexClient('api_key', 'api_secret', {timeout: 10000})

// Public API method: Get Ticker Info
poloniex.api('returnTicker')
.then((result) => {
  console.log('Ticker:', result)
})
.catch((error) => {
  console.log('Error:', error.message)
})

// Private API method: Display User's Balances
poloniex.api('returnBalances')
.then((result) => {
  console.log('Balances:', result)
})
.catch((error) => {
  console.log('Error:', error.message)
})

Legal: