Giter Club home page Giter Club logo

crypto-exchange's Introduction

crypto-exchange npm

Pulls together list of crypto exchanges to interact with their API's in a uniform fashion.

The goal of this project is to be able to interact with a number of different cryptocurrency exchange markets with one standardized package.

Available Exchanges

  • Bitfinex
  • Bittrex
  • BTC-e shutdown
  • GDAX
  • Gemini
  • Kraken
  • Liqui
  • Poloniex
  • Yunbi

Usage

  • NOTE: Pairs are expected to be in the format BASE_QUOTE
  • All methods return a promise with the result passed.

Top Level

Exchange List

List of all available exchanges from the package:

  const Exchanges = require('crypto-exchange')
  console.log(Object.keys(Exchanges))
  // [
  //   'bittrex',
  //   'gdax'
  //   'kraken',
  //   'poloniex',
  //   ...
  // ]

pairs

Quickly fetch all available pairs and which exchanges support them.

  const Exchanges = require('crypto-exchange')
  Exchanges.pairs()
    .then(console.log)
  // {
  //   BTC_USD: [ 'bitfinex', 'gdax', 'gemini', 'kraken' ],
  //   LTC_USD: [ 'bitfinex', 'gdax', 'kraken' ],
  //   LTC_BTC: [ 'bitfinex', 'bittrex', 'gdax', 'kraken', 'liqui', 'poloniex' ],
  //   ETH_USD: [ 'bitfinex', 'gdax', 'gemini', 'kraken' ],
  //   ETH_BTC: [ 'bitfinex', 'bittrex', 'gdax', 'gemini', 'kraken', 'liqui', 'poloniex' ],
  //   ETC_BTC: [ 'bitfinex', 'bittrex', 'kraken', 'poloniex' ],
  //   ETC_USD: [ 'bitfinex', 'kraken' ],
  //   RRT_USD: [ 'bitfinex' ],
  //   ...
  // }

assets

Quickly fetch all available assets and which exchanges support them.

  const Exchanges = require('crypto-exchange')
  Exchanges.assets()
    .then(console.log)
  // {
  //   BTC: [ 'bitfinex', 'bittrex', 'gdax', 'gemini', 'kraken', 'liqui', 'poloniex' ],
  //   USD: [ 'bitfinex', 'gdax', 'gemini', 'kraken' ],
  //   LTC: [ 'bitfinex', 'bittrex', 'gdax', 'kraken', 'liqui', 'poloniex' ],
  //   ETH: [ 'bitfinex', 'bittrex', 'gdax', 'gemini', 'kraken', 'liqui', 'poloniex' ],
  //   ETC: [ 'bitfinex', 'bittrex', 'kraken', 'poloniex' ],
  //   RRT: [ 'bitfinex' ],
  //   ...
  // }

Public Methods

All public methods are both accessible via a static function and an instance method. If only working with public methods, it is not neccessary to create an instance of the exchange class (one is created internally).

Both examples call the same method:

  const Exchanges = require('crypto-exchange')

  Exchanges.poloniex.ticker('BTC_USDT')
  // => Promise { <pending> }

  const poloniex = new Exchanges.poloniex(apiKeys)
  poloniex.ticker('BTC_USDT')
  // => Promise { <pending> }

ticker

Return current ticker information for a given pair on an exchange.

  ticker(pairs) {
  }
Arguments
  • pairs string, array - One or more pairs to fetch the current ticker for.
Response
  {
    'BTC_USD': {
      last: 2336.00001284,
      ask: 2337.9,
      bid: 2337,
      high: 2380,
      low: 2133,
      volume: 6597.97852916,
      timestamp: 1500461237647 // in milliseconds
    },
    ...
  }

assets

Returns the available assets on an exchange. If the asset is disabled/frozen, it is not included.

  assets() {
  }
Response
  [
    'AMP',
    'ARDR',
    'BCY',
    'BELA',
    'BLK',
    'BTC',
    ...
  ]

pairs

Returns the available pairs on an exchange.

  pairs() {
  }
Response
  [
    'BCN_BTC',
    'BELA_BTC',
    'BLK_BTC',
    'BTCD_BTC',
    'BTM_BTC',
    ...
  ]

depth

Returns the depth of available buy and sell orders.

  depth(pairs[, count = 50]) {
  }
Arguments
  • pairs string, array - One or more pairs to fetch the order book for.
  • depth number (optional) - How big of an order book to return in each direction. DEFAULT: 50
Response
  {
    'ETH_BTC': {
      'asks': [
        [
          0.06773,    // price
          10.30181086 // volume
        ],
        ...
      ],
      'bids': [
        [
          0.0676,     // price
          7.59674753  // volume
        ],
        ...
      ]
    },
    ...
  }

Authenticated Methods

To use authenticated methods, you will need to pass any necessary authentication data needed from the exchange in the constructor of the exchange.

All exchanges require a minimum of 2 items:

  • key
  • secret

Special case authentication:

  • GDAX
    • passphrase

Example:

  const Exchanges = require('crypto-exchange')

  let bittrex = new Exchanges.bittrex({
    key: '',
    secret: ''
  })

  let gdax = new Exchanges.gdax({
    key: '',
    secret: '',
    passphrase: ''
  })

buy/sell

Place a buy or sell order on an exchange.

  buy(pair, amount[, rate]) {
  }
Arguments
  • pair string - A pair value to trade against.
  • amount number - Number representing the amount of BASE to buy/sell.
  • rate number (optional) - Pass a specific rate of the pair to execute.
Response

balances

Return current total, available, and pending balances for an exchange.

  balances() {
  }
Response
  {
    'ETH_BTC': {
      balance: 0.0000,
      available: 0.0000,
      pending: 0.0000
    },
    ...
  }

address

Return or create a new address to which funds can be deposited.

Note: Due to how Coinbase and GDAX are intertwined, you must pass aditional authentication in order to interact with outside resources.

  address(sym[, opts]) {
  }
Arguments
  • sym string - The asset symbol of the address to fetch.
  • opts object (optional) - Additional options.
    • auth object - Secondary API authentication needed for Coinbase.
Response
  "0xae89158b43000e07e76b205b870a1e34653d2668"

Donate

This project is a work in progress as I'm adding more exchanges and functions. Help support this project with a โ˜• or PR!

BTC: 161kbECzKtDKfLXnC5Lwk2hgsQLtg7BNXd

ETH: 0xae89158b43000e07e76b205b870a1e34653d2668

crypto-exchange's People

Contributors

passabilities avatar niieani avatar

Stargazers

takeratta(tm)* avatar

Watchers

takeratta(tm)* avatar stephan hattinger avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.