coinbase-pro-feed
v0.1.0
Published
lightweight coinbase pro websocket feed implementation
Downloads
4
Maintainers
Readme
coinbase-pro-feed
Lightweight Coinbase Pro Websocket Feed implementation.
Install
npm install -s coinbase-pro-feed
.feedFor(product_ids[, options[, env]])
The feed wraps websocket client using stream.Readable
:
const { feedFor } = require('coinbase-pro-feed')
feedFor(['btc-eur'], { objectMode: false }) // when false
.pipe(process.stdout) // data event invokes raw buffer
feedFor(['btc-eur'], { objectMode: true }) // when true
.on('data', console.log) // data event invokes parsed object
- product_ids (default:
[]
) - options (default:
{ objectMode = true, channels: ['full'] }
) - env (default:
process.env
)
.socketFor(product_ids[, options[, env]])
The websocket client allows you to connect and listen to exchange messages.
const { feedFor } = require('coinbase-pro-feed')
socketFor(['btc-eur'], { channels })
.on('open', () => {
console.log('open') // socket connected
})
.on('data' (data) => {
console.log('data:', data) // parsed messages
})
.on('error', (err) => {
console.error('error:', err) // socket error
})
.on('close', () => {
console.log('close') // socket closed
})
Command Line Interface (CLI)
When installed globally it is possibile to access the command line interface:
npm install --global coinbase-pro-feed
Usage
coinbase-pro-feed btc-eur eth-eur ltc-eur
# stdout compatible with http://jsonlines.org