Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stoqey/finnhub
Finnhub NodeJS wrapper
https://github.com/stoqey/finnhub
candles cryptocurrency-exchanges finnhub finnhub-api forex-trading market-data nodejs-wrapper price-updates quote realtime stock-prices stocks-api ticks
Last synced: 21 days ago
JSON representation
Finnhub NodeJS wrapper
- Host: GitHub
- URL: https://github.com/stoqey/finnhub
- Owner: stoqey
- License: mit
- Created: 2020-04-02T01:18:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-10T04:28:25.000Z (over 1 year ago)
- Last Synced: 2024-11-08T14:52:10.023Z (about 1 month ago)
- Topics: candles, cryptocurrency-exchanges, finnhub, finnhub-api, forex-trading, market-data, nodejs-wrapper, price-updates, quote, realtime, stock-prices, stocks-api, ticks
- Language: TypeScript
- Homepage:
- Size: 384 KB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Finnhub - NodeJS Wrapper
#### Features
- Candles
- Tick
- Quote
- Real-time price updates
- Company Profile2
- Recommendation Trends
- Peers### Install
```
npm i @stoqey/finnhubor
yarn add @stoqey/finnhub
```### Initialize
Set env variable `FINNHUB_KEY` with the token you get from Finnhub.or simply assign it from the constructors
```ts
import FinnhubAPI, { FinnhubWS } from '@stoqey/finnhub';// For API
const finnhubAPI = new FinnhubAPI(finnHubKey);// For Websockets
const finnhubWs = new FinnhubWS(finnHubKey); // or leave finnHubKey blank if process.env.FINNHUB_KEY is set
```### Get Candles
```ts
const candles = await finnhubAPI.getCandles(symbol, startDate, endDate, '1');
```### Get Ticks
```ts
const ticks = await finnhubAPI.getTick(symbol, date);
```### Get Quote
```ts
const quote = await finnhubAPI.getQuote(symbol);
```### Get Company Profile2
```ts
const companyProfile = await finnhubAPI.getCompanyProfile2(symbol);
```### Get Recommendation Trends
```ts
const recommendations = await finnhubAPI.GetRecommendationTrends(symbol);
```### Get Peers
```ts
const peers = await finnhubAPI.getPeers(symbol);
```### Real-time price updates
```ts
finnhubWs.on("onReady", async () => {
console.log('WS is ready');
});finnhubWs.on("onData", async (data: TickData) => {
console.log('WS onData', data);
});// Add symbol to streaming list
finnhubWs.addSymbol("AAPL");// Stop streaming symbol
finnhubWs.removeSymbol("AAPL");```
##
Set `process.env.DEBUG = "finnhub*"` to see all logs