Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iam4x/treenews
An universal JavaScript client of TreeNews WebSocket
https://github.com/iam4x/treenews
Last synced: 3 months ago
JSON representation
An universal JavaScript client of TreeNews WebSocket
- Host: GitHub
- URL: https://github.com/iam4x/treenews
- Owner: iam4x
- Created: 2023-03-29T16:32:24.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-31T09:12:45.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T05:17:06.873Z (9 months ago)
- Language: TypeScript
- Size: 35.2 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TreeNews
![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/iam4x/treenews)
[![npm version](https://badge.fury.io/js/safe-cex.svg)](https://badge.fury.io/js/@iam4x/treenews)
![npm](https://img.shields.io/npm/dt/@iam4x/treenews)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/@iam4x/treenews)> An universal JavaScript client of [TreeNews](https://news.treeofalpha.com/) 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](https://www.npmjs.com/package/ws) package as well:
- `$ npm install --save ws`
## How to / Usage
Simple example:
```ts
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
```ts
{
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](https://partner.bybit.com/b/iam4x) **Up to $30,000 deposit bonus - no KYC required**
- [OKX](https://www.okx.com/join/iam4x) **Up to $10,000 deposit bonus**
- [Binance](https://accounts.binance.com/en/register?ref=KOLLSXK0)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 ❤️