API Overview
Stock SDK provides a comprehensive API for stock data access.
Quick Reference
| Category | Methods | Description |
|---|---|---|
| Real-time Quotes | getFullQuotes, getSimpleQuotes | A-Share real-time quotes |
| HK Quotes | getHKQuotes | Hong Kong stock quotes |
| US Quotes | getUSQuotes | US stock quotes |
| Fund Quotes | getFundQuotes | Mutual fund quotes |
| K-Line | getHistoryKline | Historical K-line data |
| Minute K-Line | getMinuteKline | Minute-level K-line |
| Timeline | getTodayTimeline | Today's minute timeline |
| Indicators | getKlineWithIndicators | K-line with indicators |
| Code Lists | getAShareCodeList | Get all stock codes |
| Batch | getAllAShareQuotes | Batch market queries |
| Fund Flow | getFundFlow | Capital 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
| Market | Format | Example |
|---|---|---|
| Shanghai A-Share | sh + 6 digits | sh600519 |
| Shenzhen A-Share | sz + 6 digits | sz000858 |
| Beijing A-Share | bj + 6 digits | bj430047 |
| HK Stock | 5 digits | 00700 |
| US Stock (quote) | Ticker | AAPL |
| US Stock (K-line) | Market + Ticker | 105.MSFT |
US Stock Market Codes
105- NASDAQ106- NYSE107- 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';