Skip to content
Velo

channels.feed

Describes a subscription to one or more channels. Nothing connects until the feed is executed with velo.watch().

Imports

import { Velo } from 'velo-sdk';

Example

Attach listeners to each channel, then pass the channels to velo.channels.feed():

const velo = new Velo({ apiKey: process.env.VELO_API_KEY! });
const product = {
  exchange: 'binance-futures',
  coin: 'BTC',
  product: 'BTCUSDT',
} as const;
 
const price = velo.channels.price(product).on({
  data: (row) => console.log(row.time, row.close_price),
  error: ({ reason }) => console.error('Price channel error:', reason),
});
 
const openInterest = velo.channels.openInterest({ coin: product.coin }, { metric: 'coins' }).on({
  data: (entries) => console.table(entries),
  error: ({ reason }) => console.error('Open interest channel error:', reason),
});
 
const watcher = await velo.watch(velo.channels.feed([price, openInterest]), {
  on: {
    error: (error) => console.error('Connection error:', error),
    close: ({ code, reason }) => console.log('Connection closed:', code, reason),
  },
});

Definition

function feed(channels: readonly Channel[]): ChannelsFeedBuilder;

Parameters

channels

  • Type: readonly Channel[]
  • Required

A non-empty array of velo.channels channels, each with a .on({ data }) listener. Indicators, products, coins, and markets can be mixed.

Invalid entries, missing data listeners, or conflicting kinds for the same channel name throw a VeloError.

Return Type

  • Type: ChannelsFeedBuilder

Returns an immutable subscription builder for the selected channels.

See Managing subscriptions for adding and removing channels from a running feed.