Skip to content

API Overview

Stock SDK provides a comprehensive API for stock data access.

Quick Reference

CategoryMethodsDescription
Real-time QuotesgetFullQuotes, getSimpleQuotesA-Share real-time quotes
HK QuotesgetHKQuotesHong Kong stock quotes
US QuotesgetUSQuotesUS stock quotes
Fund QuotesgetFundQuotesMutual fund quotes
K-LinegetHistoryKlineHistorical K-line data
Minute K-LinegetMinuteKlineMinute-level K-line
TimelinegetTodayTimelineToday's minute timeline
IndicatorsgetKlineWithIndicatorsK-line with indicators
Code ListsgetAShareCodeListGet all stock codes
BatchgetAllAShareQuotesBatch market queries
Fund FlowgetFundFlowCapital flow data

SDK Initialization

typescript
import { StockSDK } from 'stock-sdk';

const sdk = new StockSDK();

// With configuration
const sdk = new StockSDK({
  baseUrl: '/api/proxy',  // Custom API endpoint
  timeout: 10000,         // Request timeout (ms)
});

Stock Code Format

MarketFormatExample
Shanghai A-Sharesh + 6 digitssh600519
Shenzhen A-Sharesz + 6 digitssz000858
Beijing A-Sharebj + 6 digitsbj430047
HK Stock5 digits00700
US Stock (quote)TickerAAPL
US Stock (K-line)Market + Ticker105.MSFT

US Stock Market Codes

  • 105 - NASDAQ
  • 106 - NYSE
  • 107 - Other

Error Handling

typescript
try {
  const quotes = await sdk.getSimpleQuotes(['sh600519']);
} catch (error) {
  if (error instanceof Error) {
    console.error('Error:', error.message);
  }
}

Type Exports

Stock SDK exports all TypeScript types:

typescript
import {
  StockSDK,
  FullQuote,
  SimpleQuote,
  HKQuote,
  USQuote,
  FundQuote,
  KlineData,
  TimelineData,
  FundFlowData,
  // ... and more
} from 'stock-sdk';

Released under the ISC License.