@fugle/marketdata
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Fugle MarketData

NPM version Build Status Coverage Status

Fugle MarketData API client library for Node.js

Installation

$ npm install --save @fugle/marketdata

Importing

// Using Node.js `require()`
const { RestClient, WebSocketClient } = require('@fugle/marketdata');

// Using ES6 imports
import { RestClient, WebSocketClient } from '@fugle/marketdata';

Usage

The library is an isomorphic JavaScript client that supports REST API and WebSocket.

REST API

const client = new RestClient({ apiKey: 'YOUR_API_KEY' });

const stock = client.stock;   // Stock REST API client
const futopt = client.futopt; // Futures & Options REST API client

stock.intraday.quote({ symbol: '2330' })
  .then(data => console.log(data));

WebSocket API

const client = new WebSocketClient({ apiKey: 'YOUR_API_KEY' });

const stock = client.stock;   // Stock WebSocket API client
const futopt = client.futopt; // Futures & Options WebSocket API client

// open the WebSocket connection and authenticate
stock.connect().then(() => {
  // subscribe the channel to receive streaming data
  stock.subscribe({ channel: 'trades', symbol: '2330' });
});

stock.on('message', (message) => {
  const data = JSON.parse(message);
  console.log(data);
});

License

MIT

Package Sidebar

Install

npm i @fugle/marketdata

Weekly Downloads

41

Version

1.1.0

License

MIT

Unpacked Size

44.8 kB

Total Files

55

Last publish

Collaborators

  • fugle-dev
  • starshine
  • chunkai1312
  • bistin