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

crypto-socket

v4.0.0

Published

Basic cryptocurrency ticker supporting multiple exchanges and currencies with websockets where available.

Downloads

93

Readme

crypto-socket

** Ronaldo Barbachano, 2016 **

*** Provided as is. ***

Combines public crypto currency websocket API's to provide a low-resource, zero configuration ticker. Each exchange, except for bittrex, uses a realtime websocket.

Supported exchanges

bittrex,bitstamp,poloniex,gdax,gemini,cex,bitfinex,okcoin,bitmex

Quickstart

cryptoSocket = require("crypto-socket")
cryptoSocket.start();
  1. Get ticker quotes via cryptoSocket.echoExchange() or access object variable cryptoSocket.Exchanges

Basic functions

cryptoSocket.start(exchange,symbol)

Starts a websocket. Where exchange is always lowercase and symbol is always upper-case.

// listen to ETHBTC on bitfinex,bitmex,and cex.
cryptoSocket.start("bitfinex","ETHBTC")
cryptoSocket.start("bitmex","ETHBTC")
cryptoSocket.start("cex","ETHBTC")

Supported for bitfinex and bittrex

Pass an array to subscribe to multiple markets

cryptoSocket.start("bitfinex",['LTCBTC','BTCUSD'])

These exchanges should support all markets that they have, and will be simple to add more.

Note

As of now Poloniex exchange only has one open socket that sends back all data. The above syntax is not recommeneded unless you are only following one symbol; as it will open up multiple sockets that return all data, and filter out your selections.


echoExchange()

A simple printout of all open ticker quotes.

// print out quotes every 1000 ms (1 second)
setInterval(
	function(){
		cryptoSocket.echoExchange()
	},1000);

cryptoSocket.Exchanges

Access to the raw variable the module uses to store ticker quotes as they update. One value at a time.

// get bitfinex quotes
console.log(cryptoSocket.Exchanges['bitfinex'])
// renders '{ ETHBTC: 0.02492 }' to console.

FAQ

** Does this store data? **

Nope. Ticker values (in most cases last sale price) is stored in memory.

*** Why? ***

Other popular BTC average modules require incredible amount of bandwidth at regular intervals which can make deployment difficult in many situations. Websockets are obviously the way to go for real time data, as constantly querying many exchanges can be taxing.

This module does not include exchange API's that do not have web sockets. Why? Theres a billion other modules that do something similar, and perhaps this is a wake up call to any exchange that does not offer rhobust websocket support.

Many developers would rather not be bothered reading through additional API documentation which, in many cases, is incomplete, hard to follow and usually lacking node.js examples. I did it for you! In node. You're welcome.

Why Should I use websockets?

They are (usually) faster. Data is sent to the client as its received, versus a poll-and-diff approach which requires regular polling intervals. This can mean the difference between a constant 10k/s stream versus a sporadic 3k/s steam. Sites that poll many exchanges regularly increase bandwith use based on polling intervals. (For example if you attempt to use BTCAverage module, and three times a second, you can easily consume 300k/s) This module with all websockets activated consumes around 3-10k/s making it possible for low-bandwith enviornments to function somewhat efficently.

Why are some symbols unavailable?

The exchange's api does not offer the symbol via websocket or laziness. Hook it up with a PR brah; after a while one gets burnt out glazing over poorly written/organized API documentation; and its all subject to change at any given moment so prepare for this to break.

Why are some exchanges unavailable?

For the most part they do not offer a public web socket and I did not feel it nessary to reduplicate more code to create a 'faux-socket', as there are many alternatives.

Donation address

ETH - 0x9d7c3b85e4273E24C007481a8DB074f0FB2df5c8