GithubHelp home page GithubHelp logo

lucklo / kraken-exchange-api Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 5.0 49 KB

Unofficial Node.js client library for Kraken Exchange API (https://kraken.com)

License: Apache License 2.0

JavaScript 100.00%
kraken kraken-exchange-api bitcoin bitcoin-exchange

kraken-exchange-api's Introduction

kraken-exchange-api

Build Status

Quick Start

Status

This project is still in very early development and some major functionality is probably missing. All documented endpoints and objects should be usable though.

If you like to contribute feel free to contact author of this repo or push Pull Request with changes.

Installation

Please install this package using npm kraken-exchange-node-api

npm install kraken-exchange-node-api

Requirements

This library was written in ES2015 code. We highly recommenda any version of Node.js greater than 7.

API Clients

API Clients provide simple way to use Kraken API directly without need to use Classes that we provided.

Public API Client

Kraken Exchange provide set of endpoints that don't require authentication to get basic information about Market. See Public market data section at Kraken Docs

Authenticated API Client

To access Private API from Kraken you need to request ApiKey and ApiSecret from your Account Settings in Kraken Dashboard.

Built-In Kraken API Support

Every Class we created provide both Promise and callback interface.

Kraken.Time

getUnixTime()

Kraken.Time.getUnixTime(/** optional **/ callback) 
  • Arguments:
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: integer

getTimeinRfc1123()

Kraken.Time.getTimeInRfc1123(/** optional **/ callback) 

Returns RFC1123 compilant timestamp string.

  • Arguments:
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: string
Example Usage:
const Kraken = require('kraken-exchange-node-api')
const time = new Kraken.Time()

// Promise Based
time
  .getUnixTime()
  .then((unixTimeStamp) => {
    console.log(unixTimeStamp)
  })


// Callback Based
time
  .getUnixTime((unixTimeStamp) => {
    console.log(unixTimeStamp)
  })

Kraken.Assets

getAssets()

Kraken.Assets.getAsset(assets, /** optional **/ callback) 

Returns specified assets information.

  • Arguments:
    • assets (required) - Array of assets i.e ['XBT', 'ETH']
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: Array of Assets

getAsset()

Kraken.Assets.getSingleAsset(asset, /** optional **/ callback) 

Returns single specific asset information.

  • Arguments:
    • asset (required) - Asset identifier i.e. XBT
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: Object of Asset

getAllAssets()

Kraken.Assets.getAllAssets(/** optional **/ callback) 

Returns information about all assets

  • Arguments:
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: Array of Assets

Kraken.AssetPairs

getAssetPairs()

Kraken.AssetPairs.getAssetPairs(assetPairs, /** optional **/ callback) 

Returns information about specified asset pairs

  • Arguments:
    • assetPairs (required) - Array of asset pairs i.e [XBTEUR', 'XBTUSD']
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: Array of Assets Pairs

getSingleAssetPair()

Kraken.AssetPairs.getSingleAssetPair(assetPair, /** optional **/ callback) 

Returns single specific asset pair information.

  • Arguments:
    • assetPair (required) - Asset pair identifier i.e. XBTEUR
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: Object of Asset Pair

getAllAssetPairs()

Kraken.AssetPairs.getAllAssetPairs(/** optional **/ callback) 

Returns information about all asset pairs

  • Arguments:
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: Array of Asset Pairs

Kraken.Ticker

Provides interface to retrieve Ticker information about given Asset Pairs.

Example Usage:
const ticker = new Kraken.Ticker()
const parts = Kraken.TickerParts

ticker.getSinglePairTicker('XBTEUR')
   .then((ticker) => {	 
     const [volumeWeightedAveragePriceLast24h, volumeLast24h] = ticker.getParts([parts.VolumeWeightedAveragePriceLast24h, parts.VolumeLast24h])
     const spread = ticker.getAskPrice() - ticker.getBidPrice()
     console.log(ticker.getPairName(), spread, volumeWeightedAveragePriceLast24h, volumeLast24h)
   })

getPairsTickers()

Kraken.Ticker.getPairsTickers(assetPairs, /** optional **/ callback) 

Returns ticker information about specified asset pairs

  • Arguments:
    • assetPairs (required) - Array of asset pairs i.e [XBTEUR', 'XBTUSD']
    • callback (optional)
  • Returns: Promise
    • Resolved Value Type: Array of TickerInfo Objects for selected Pairs

getSinglePairTicker()

Kraken.Ticker.getSinglePairTicker(assetPair, /** optional **/ callback) 

Returns ticker info of single specific asset pair

  • Arguments:
    • assetPair (required) - Asset pair identifier i.e. XBTEUR
    • callback (optional)
  • Returns: Promise

Info Objects

TickerInfo

Class that encapsulate data for single Ticker. It's useful for retrieving specific information about Ticker in easy & readable way.

TickerInfo.getAskPrice()

TickerInfo.getAskPrice() 

Returns Ask Price of Ticker i.e 2487.55089

  • Returns: float

TickerInfo.getBidPrice()

TickerInfo.getBidPrice() 

Returns Bid Price of Ticker i.e. 2487.55089

  • Returns: float

TickerInfo.getPairName()

TickerInfo.getBidPrice() 

Returns pair name of Ticker object i.e. XXBTZEUR

  • Returns: string

TickerInfo.getPart(part)

TickerInfo.getPart(/** required **/ part)

Returns selected part of ticker. Keep in mind that floats values (i.e. prices) won't be casted to float type.

  • Arguments:
    • part (required) - Array of ticker parts (see. TickerParts)
  • Returns: string|int

TickerInfo.getParts()

TickerInfo.getParts(/** required **/ partsArray) 

Returns selected parts of ticker. Order is being kept as in input params

  • Arguments:
    • partsArray (required) - Array of ticker parts (see. TickerParts)
  • Returns: Array with values of selected Ticker parts

TickerInfo.getRawData()

TickerInfo.getRawData() 

Returns raw response from Kraken API in form of Object

  • Returns: Object

Object Parts (Dictionaries)

TickerParts

Provides parts available in TickerInfo that are provided by Kraken API. Following parts are supported:

  • AskPrice
  • AskWholeLotVolume
  • AskLotVolume
  • BidPrice
  • BidWholeLotVolume
  • BidLotVolume
  • ClosePrice
  • CloseLotVolume
  • VolumeToday
  • VolumeLast24h
  • VolumeWeightedAveragePriceToday
  • VolumeWeightedAveragePriceLast24h
  • TradesToday
  • TradesLast24h
  • LowPriceToday
  • LowPriceLast24h
  • HighPriceToday
  • HighPriceLast24h
  • OpenPrice

kraken-exchange-api's People

Contributors

lucklo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kraken-exchange-api's Issues

Package not found

Hi Lucklo

Nice project and well documented!

However when installing it via npm I cannot run my project because of a could not find package "kraken-exchange-node-api"

I noticed that there was no index.js in the root of the package. Copying the contents of lib to the root fixed the issue.

Cheers

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.