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

kraken-js-client

v1.1.10

Published

The Kraken Exchange API for Node.js

Downloads

7

Readme

kraken-exchange-api

Build Status

Quick Start

Status

This is a fork of Kraken node api by lucklo

Why i forked ? Because it was missing hole private section and i found this as the best kraken js client to start from.

My goals:

  • Convert it to typescript for smoother development
  • Make it usable in all nodejs versions and browsers (not atm).
  • Implement retry system since kraken is unstabble atm
  • Create typings for easier use

Installation

Install this package using npm

npm install kraken-js-client

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

Basic usage:


const KrakenClient = require('Kraken').Kraken; // High level class stores all clients

/**
 * Kraken constructor: 
 * constructor(opts?: IKrakenConfiguration, auth?: IAuthOpts)
 * 
 * KrakenConfiguration: 
 * 
 * interface IKrakenConfiguration {
 *     retryCount?: number;
 *     retryDelay?: number;
 *     apiUrl?: string;
 *     apiVersion?: string;
 *     logLevel?: string;
 * }
 * 
 * 
 * AuthOpts: 
 * 
 * interface IAuthOpts {
 *     apiKey: string;
 *     apiSecret: string;
 * }
 *
 */

const AuthOpts = {
    apiKey: 'testApiKey',
    apiSecret: 'testApiSecret'
};

const Kraken = new KrakenClient({}, AuthOpts);

// Alternate way
const Kraken = new KrakenClient({
    retryDelay: 1000
}); 

/**
 * Alternate way to add auth credentials if not passed wo constructor
 */
Kraken.withAuth(AuthOpts);

Kraken.Balance.get().then(console.log);

Require individual clients


const Time = require('node-js-client').Time;

let time = new Time();

const Balance = require('node-js-client').Balance;

let balance = new Balance({
    auth: AuthOpts,
    http: {
        retryDelay: 1000
    }
});

balance.get().then(console.log);

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-js-client').Kraken;
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