stock-api
stock-api is a TypeScript library for querying real-time stock market data across Chinese A-shares, US stocks, and Hong Kong stocks. It runs in Node.js, browsers, CLI, and as an MCP tool with zero production dependencies and automatic fallback between multiple data sources.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | zhangxiangliang/stock-api |
| Owner | zhangxiangliang |
| Primary language | TypeScript |
| License | MIT — OSI-approved |
| Stars | 1.7k |
| Forks | 194 |
| Open issues | 1 |
| Latest release | v2.7.3 (2026-06-24) |
| Last updated | 2026-07-08 |
| Source | https://github.com/zhangxiangliang/stock-api |
What stock-api is
Built in TypeScript with zero runtime dependencies, stock-api abstracts multiple third-party stock data providers (Tencent, Sina, Eastmoney) behind a unified API. It supports single/batch stock queries, K-line charting, search, and exposes capabilities via Node.js modules, browser bundles (IIFE), CLI commands, and MCP protocol integration.
Get the stock-api source
Clone the repository and explore it locally.
git clone https://github.com/zhangxiangliang/stock-api.gitcd stock-api# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Verify third-party data source terms of service and rate limits before production deployment; project does not guarantee continued API access.
- Handle fallback logic: auto mode tries tencent → sina → eastmoney in sequence; plan for partial/failed responses when sources are unavailable.
- Stock code format strictly requires SH/SZ/HK/US prefixes; validate user input before querying to avoid silent failures.
- Node.js ≥18 required; ensure browser target compatibility when using the CDN bundle (check minified size and CORS headers on jsdelivr).
- No built-in caching, rate-limiting, or request batching; implement client-side caching and request deduplication for high-frequency UIs.
When to avoid it — and what to weigh
- Requires guaranteed data accuracy or regulatory compliance — Project explicitly disclaims data accuracy, completeness, and real-time guarantees. Third-party sources may change terms or availability. Financial institutions and trading firms must validate independently and confirm compliance with financial regulations.
- Need high-frequency or low-latency trading — Designed for periodic queries and dashboards, not sub-millisecond market data feeds. Depends on external third-party APIs which may introduce latency and rate limiting constraints.
- Require SLA guarantees and dedicated support — Open-source MIT project maintained by individuals; no commercial SLA, uptime guarantees, or vendor support. Third-party data sources (Tencent, Sina, Eastmoney) can break without notice.
- Cannot accept third-party data source dependencies — No internal data infrastructure; relies entirely on reverse-engineered or public APIs from external Chinese and international financial services. Service continuity depends on those providers.
License & commercial use
MIT License (permissive OSI-approved). Allows commercial use, modification, and distribution with attribution and no warranty. No patent or trademark restrictions stated.
MIT permits commercial use. However, project disclaims data accuracy and continuity; third-party data sources have their own terms. Before commercial deployment (trading, advisory, fintech), independently verify compliance with financial regulations, data provider ToS, and liability assumptions. No commercial support or indemnification from project maintainer.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
No encryption, authentication, or authorization primitives in the library. Data flows over HTTPS to third-party providers (not verified in provided data). Browser bundle is minified but sourced from CDN; verify integrity hash. No mention of input sanitization for stock codes or search queries; supply malformed codes to untrusted endpoints at your own risk. Depends on third-party API security posture (not audited or documented).
Alternatives to consider
TradingView (proprietary / freemium SaaS)
Offers real-time charting, multiple data sources, and API; includes compliance/SLA but higher cost and less transparent data attribution than stock-api's open-source modular design.
yfinance (Python, Yahoo Finance wrapper)
Python equivalent for historical and real-time US/international data; larger ecosystem and documentation but US-centric; lacks A-share and MCP integration.
Akshare (Python, multi-source Chinese financial data)
Chinese fintech data library with A-share, futures, bonds coverage; more mature ecosystem but Python-only; no browser or MCP support, heavier dependencies.
Build on stock-api with DEV.co software developers
Evaluate stock-api for your dashboard, trading tool, or AI agent. Review third-party data provider terms and compliance requirements before production use. Devco can help you architect data pipelines, validate integrations, and plan fallback strategies.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
stock-api FAQ
Is stock-api suitable for production trading or investment advice?
What happens if a data source API breaks or gets rate-limited?
Can I use stock-api in my proprietary app under MIT license?
Does stock-api include historical backtesting or advanced charting?
Custom software development services
From first prototype to production, DEV.co delivers software development services around tools like stock-api. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across mcp servers and beyond.
Ready to integrate live stock data?
Evaluate stock-api for your dashboard, trading tool, or AI agent. Review third-party data provider terms and compliance requirements before production use. Devco can help you architect data pipelines, validate integrations, and plan fallback strategies.