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

bitcoinaverage

v1.4.3

Published

Official library of BitcoinAverage API

Downloads

3,078

Readme

This library enables quick and easy access to our Bitcoin, Ethereum, Litecoin, Ripple and other cryptocurrency exchange rates.

Install

npm install bitcoinaverage

Setup

Get your public and private keys from our website and you are ready to run these examples.

const ba = require('bitcoinaverage');

var publicKey = 'yourPublicKey';

var restClient = ba.restfulClient(publicKey);
var wsClient = ba.websocketClient(publicKey);

Ticker Data

The response received by https://apiv2.bitcoinaverage.com/indices/global/ticker/BTCUSD.

The symbol_set can be one of: local, global, crypto and tokens.

The symbol can be any pair from our Full symbol list

var symbol_set = 'global';
var symbol = 'BTCUSD';

restClient.getTickerDataPerSymbol('global', 'BTCUSD', function(response) {
    console.log(response);
}, function(error){
    console.log(error);
}) ;

Exchange Data

All price data from single exchange

restClient.perExchangeData('bitstamp',
    function(response){
        console.log(response);
    },
    function(err){
        console.log(err);
    });

Data from all exchanges for one symbol

restClient.allExchangeDataForSymbol('BTCGBP',
    function(response){
        console.log(response);
    },
    function(err){
        console.log(err);
    });

Websocket

Connect to one of our websocket endpoints and get real-time updates for the Bitcoin Global Price Index.

Ticker websocket

wsClient.connectToTickerWebsocket('global', 'BTCUSD', function(response) {
    console.log(response);
}, function(error){
    console.log(error)
}, function(){
    console.log("websocket closed");
});

Websocket V2

Enterprise users can access our new and improved version 2 of our Websocket API. It provides faster updates and supports multiple symbols in a single connection.

Ticker websocket V2

wsClient.connectToTickerWebsocketV2('tokens', ['OMGETH', 'EOSBTC'], function(response) {
    console.log(response);
}, function(error){
    console.log(error)
}, function(){
    console.log("websocket closed");
});

Orderbook websocket

var symbols = ['BTCUSD', 'ETHUSD'];
var exchange = 'bitfinex';
var ORDERBOOKS = {
    BTCUSD: {},
    ETHUSD: {}
};
var symbol = '';
ws.connectToOrderbookWebsocket(exchange, symbols, function(response){
    symbol = respnose.data.symbol;
    if(response.data.type === "snapshot"){
        ORDERBOOKS[symbol].asks = response.data.asks;
        ORDERBOOKS[symbol].bids = response.data.bids;
     }else{
       console.log(response.data.updates);
       for (var i = 0; i < response.data.updates.length; i++){
          var item = response.data.updates[i];
         if(item.amount === 0){
            delete(ORDERBOOKS[symbol][item.side][item.price]);
         }else{
           ORDERBOOKS[symbol][item.side][item.price] = item;
         }
       }
     }
}, function(err){
console.log(err);
});

Websockets V3

The latest version of our websocket module is available via our Grow and Dominate plans as well as the legacy Enterprise users.

Our version 3 builds on top of version 2 with added improvements in reliability, speed and flexibility.

Ticker websocket V3

wsClient.connectToTickerWebsocketV3('global', ['BTCUSD', 'BTCEUR', 'BTCGBP'], function(response) {
    console.log("Success", response);
}, function(error){
    console.log(error)
}, function(){
    console.log("websocket closed");
});

Exchange websocket V3

Version 3 of our exchange websocket channel allows you to subscribe only to the symbols you need from a particular exchange.

wsClient.connectToOrderbookWebsocketV3('coinbasepro', ['BTCUSD', 'LTCEUR', 'ETHBTC'], function(response) {
    console.log("Success", response);
}, function(error){
    console.log(error)
}, function(){
    console.log("websocket closed");
});

Orderbook websocket V3

Subscribe to live orderbook updates from multiple symbols from single exchange.

Supported exchanges are: Coinbasepro, Bitstamp, Bitfinex, Binance, Bittrex and Kraken.

wsClient.connectToOrderbookWebsocketV3('coinbasepro', ['BTCUSD', 'LTCEUR', 'ETHBTC'], function(response) {
    console.log("Success", response);
}, function(error){
    console.log(error)
}, function(){
    console.log("websocket closed");
});

Trades websocket v3

Subscribe to live trades updates from multiple symbols from single exchange.

Supported exchanges are: Coinbasepro, Bitstamp, Bitfinex, Binance, Bittrex and Kraken.

wsClient.connectToTradesWebsocketV3('coinbasepro', ['BTCUSD', 'LTCEUR', 'ETHBTC'], function(response) {
    console.log("Success", response);
}, function(error){
    console.log(error)
}, function(){
    console.log("websocket closed");
});