Skip to main content
const stream = client.streamPrices([0, 1]);

stream.onSnapshot(ticks => {
  console.log(ticks);
});

stream.onTick(tick => {
  console.log(tick.pair, tick.mid);
});
You can update subscriptions dynamically:
stream.subscribe([2]);
stream.unsubscribe([1]);

Response schema

interface Response {
  onSnapshot(handler: (ticks: PriceTick[]) => void): () => void;
  onTick(handler: (tick: PriceTick) => void): () => void;
  onOpen(handler: () => void): this;
  onError(handler: (event: Error) => void): this;
  onClose(handler: (code: number, reason: string) => void): this;
  subscribe(pairIds: Array<string | number>): this;
  unsubscribe(pairIds: Array<string | number>): this;
  close(): void;
  readonly readyState: number;
}

interface PairSchedule {
  id: number;
  alwaysOpen?: boolean;
  timezone?: string;
  openingHours?: string[];
}

interface PriceTick {
  pairId?: string;
  feedId: string;
  pair: string;
  from: string;
  to: string;
  bid: number;
  mid: number;
  ask: number;
  isMarketOpen: boolean;
  isDayTradingClosed: boolean;
  secondsToToggleIsDayTradingClosed: number;
  timestampSeconds: number;
  schedule?: PairSchedule;
}