npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

infoway-sdk

v0.1.2

Published

Official Node.js/TypeScript SDK for Infoway real-time financial data API

Readme

Infoway SDK for Node.js / TypeScript

npm version Node.js License: MIT

English | 中文

Official Node.js/TypeScript SDK for the Infoway real-time financial data API.

API Documentation | Get API Key

Get your free API key at infoway.io -- 7-day free trial

Installation

npm install infoway-sdk
# or
yarn add infoway-sdk
# or
pnpm add infoway-sdk

Requirements: Node.js >= 18.0.0

Quick Start

REST API

import { InfowayClient, KlineType } from "infoway-sdk";

const client = new InfowayClient({ apiKey: "YOUR_API_KEY" });

// Stock trade data
const trades = await client.stock.getTrade("AAPL.US");
console.log(trades);

// Multiple symbols
const multiTrades = await client.stock.getTrade("AAPL.US,TSLA.US,GOOGL.US");

// Order book depth
const depth = await client.stock.getDepth("AAPL.US");

// K-line data
const klines = await client.stock.getKline("AAPL.US", KlineType.DAY, 100);

// Crypto data
const btc = await client.crypto.getTrade("BTCUSDT");
const ethKline = await client.crypto.getKline("ETHUSDT", KlineType.HOUR_1, 50);

// Market temperature
const temp = await client.market.getTemperature("HK,US");

// Market breadth
const breadth = await client.market.getBreadth("US");

// Stock fundamentals
const valuation = await client.stockInfo.getValuation("AAPL.US");
const ratings = await client.stockInfo.getRatings("AAPL.US");

// Plate/sector data
const industries = await client.plate.getIndustry("HK");
const concepts = await client.plate.getConcept("HK");

// Basic info
const symbols = await client.basic.getSymbols("US");
const tradingDays = await client.basic.getTradingDays("US");

Environment Variable

You can set INFOWAY_API_KEY instead of passing it directly:

export INFOWAY_API_KEY=your_api_key
const client = new InfowayClient(); // reads from INFOWAY_API_KEY

WebSocket Real-time Data

import { InfowayWebSocket, Business } from "infoway-sdk";

const ws = new InfowayWebSocket({
  apiKey: "YOUR_API_KEY",
  business: Business.STOCK,
});

ws.onTrade = (msg) => {
  console.log("Trade:", msg);
};

ws.onDepth = (msg) => {
  console.log("Depth:", msg);
};

ws.onKline = (msg) => {
  console.log("Kline:", msg);
};

ws.onDisconnect = () => {
  console.log("Disconnected, reconnecting...");
};

ws.onReconnect = () => {
  console.log("Reconnected!");
};

// Subscribe after connection is established
await ws.subscribeTrade("AAPL.US,TSLA.US");
await ws.subscribeDepth("AAPL.US");

// Start receiving data
await ws.connect();

// To close:
// await ws.close();

Crypto WebSocket

const ws = new InfowayWebSocket({
  apiKey: "YOUR_API_KEY",
  business: Business.CRYPTO,
});

ws.onTrade = (msg) => console.log("Crypto trade:", msg);
await ws.subscribeTrade("BTCUSDT,ETHUSDT");
await ws.connect();

API Reference

REST Clients

| Client | Prefix | Description | |--------|--------|-------------| | client.stock | stock | HK, US, CN stock market data | | client.crypto | crypto | Cryptocurrency data | | client.japan | japan | Japan stock market data | | client.india | india | India stock market data | | client.common | common | Common market data | | client.basic | -- | Symbols, trading days, hours | | client.market | -- | Temperature, breadth, indexes | | client.plate | -- | Industry/concept sectors | | client.stockInfo | -- | Valuation, ratings, company info |

Market Data Methods (stock/crypto/japan/india/common)

| Method | HTTP | Endpoint | |--------|------|----------| | getTrade(codes) | GET | /{prefix}/batch_trade/{codes} | | getDepth(codes) | GET | /{prefix}/batch_depth/{codes} | | getKline(codes, klineType, count) | POST | /{prefix}/v2/batch_kline |

KlineType Enum

| Value | Interval | |-------|----------| | KlineType.MIN_1 (1) | 1 minute | | KlineType.MIN_5 (2) | 5 minutes | | KlineType.MIN_15 (3) | 15 minutes | | KlineType.MIN_30 (4) | 30 minutes | | KlineType.HOUR_1 (5) | 1 hour | | KlineType.HOUR_2 (6) | 2 hours | | KlineType.HOUR_4 (7) | 4 hours | | KlineType.DAY (8) | 1 day | | KlineType.WEEK (9) | 1 week | | KlineType.MONTH (10) | 1 month | | KlineType.QUARTER (11) | 1 quarter | | KlineType.YEAR (12) | 1 year |

WebSocket Codes

Client → server:

| Code | Name | Description | |------|------|-------------| | 10000 | SUB_TRADE | Subscribe to trade data | | 10003 | SUB_DEPTH | Subscribe to depth data | | 10006 | SUB_KLINE | Subscribe to K-line data (payload data.arr=[{codes, type}]) | | 10010 | HEARTBEAT | Heartbeat keepalive | | 11000 | UNSUB_TRADE | Unsubscribe trade data | | 11001 | UNSUB_DEPTH | Unsubscribe depth data | | 11002 | UNSUB_KLINE | Unsubscribe K-line data |

Server → client:

| Code | Name | Description | |------|------|-------------| | 10001 | SUB_TRADE_ACK | Trade subscribe acknowledgement | | 10002 | PUSH_TRADE | Real-time trade push | | 10004 | SUB_DEPTH_ACK | Depth subscribe acknowledgement | | 10005 | PUSH_DEPTH | Real-time depth push | | 10007 | SUB_KLINE_ACK | K-line subscribe acknowledgement | | 10008 | PUSH_KLINE | Real-time K-line push | | 11010 | UNSUB_ACK | Unsubscribe acknowledgement |

Error Handling

import { InfowayAPIError, InfowayAuthError, InfowayTimeoutError } from "infoway-sdk";

try {
  const data = await client.stock.getTrade("AAPL.US");
} catch (err) {
  if (err instanceof InfowayAuthError) {
    console.error("Authentication failed. Check your API key.");
  } else if (err instanceof InfowayTimeoutError) {
    console.error("Request timed out.");
  } else if (err instanceof InfowayAPIError) {
    console.error(`API error [${err.ret}]: ${err.msg}`);
  }
}

License

MIT