coinbase / coinbase-pro-node

DEPRECATED — The official Node.js library for Coinbase Pro
Apache License 2.0
844 stars 316 forks source link

Get multiple product tickers in one call? #363

Closed unicornsoftwareinc closed 4 years ago

unicornsoftwareinc commented 5 years ago

Hi there, is there some way to get multiple product tickers with one call? I only see the "getProductTicker" function unless I'm missing something.

Thanks

vansergen commented 5 years ago

@hugeprestigellc You can use ticker channel for that:

const { WebsocketClient } = require('coinbase-pro');
const channels = ['ticker'];
const product_ids = ['BTC-USD', 'ETH-USD', 'ETH-USDC', 'LINK-ETH'];
const ws_url = 'wss://ws-feed.pro.coinbase.com';
const websocket = new WebsocketClient(product_ids, ws_url, null, { channels });
websocket.on('message', message => {
  if (message.type === 'ticker') {
    // new ticker
    console.log(message);
  }
});
drewrothstein commented 4 years ago

Hi, we are closing out PRs + Issues as this project is being archived.