/treenews

An universal JavaScript client of TreeNews WebSocket

Primary LanguageTypeScript

TreeNews

Snyk Vulnerabilities for GitHub Repo npm version npm npm bundle size

An universal JavaScript client of TreeNews WebSocket

Written in TypeScript with definitions typings

Installation

  • $ npm install --save @iam4x/treenews

If you are working in a node.js/server environment, you need to install ws package as well:

  • $ npm install --save ws

How to / Usage

Simple example:

import { TreeNews } from '@iam4x/treenews';

const treeNews = new TreeNews({
  onNews: (news) => console.log(JSON.stringify(news, null, 4));
});

// connect to websocket
treeNews.start();

// close connection to websocket
treeNews.stop();

Options

{
  autoReconnect?: boolean; // default: true
  autoReconnectTimeout?: number; // default: to 1 second (in seconds)
  autoStart?: boolean;
  apiKey?: string;
  debug?: boolean;
  onOpen?: (event: Event) => void;
  onError?: (event: Event) => void;
  onNews?: (news: News) => void;
  onMessage?: (event: MessageEvent) => void;
  onClose?: (event: CloseEvent) => void;
}

Donations

If you found this project interesting or useful, create accounts with my referral links:

  • Bybit Up to $30,000 deposit bonus - no KYC required
  • OKX Up to $10,000 deposit bonus
  • Binance

Or buy me a coffee with a crypto donation:

  • ETH/BSC/MATIC: 0xFF2da578C73bC694fd767A1CC77160002C2003E6

Changelog

v1.0.0 - (03/29/2023)

  • Initial release

Contributions & Pull Requests

Feel free to create issues, PRs and start a discussion ❤️