stock-api

by zhangxiangliang

TypeScript stock market data tool supporting A-share, Hong Kong, and US stock quotes. Supports Node.js, browser, CLI, and MCP usage with zero runtime dependencies. No external data files required.

Financestdio or Streamable HTTPCommunity

Repository-wide counts · Cached 2026-06-22

Overview

The stock-api MCP server is a publicly available project. Review the upstream repository for installation instructions, supported tools, compatibility, permissions, and current maintenance status.

Configuration

Configuration, transport, authentication, and runtime requirements vary by project. Open the repository before connecting and use the smallest set of credentials and permissions required.

Open the stock-api repository to read the latest documentation.

KEEP EXPLORING

Compare source, connection, and authentication details before choosing an implementation.

View the complete category

Financial Datasets MCP Server

financial-datasets

Community

一个模型上下文协议(MCP)服务器,提供股票市场数据的访问,包括财务报表(收入表、资产负债表、现金流量表)、股票价格和市场新闻。需要通过环境变量 FINANCIAL_DATASETS_API_KEY 设置 API 密钥,配置在 .env 文件中。

a-share-mcp

24mlight

Community

A MCP 服务器,专注于A股市场,提供股票基础信息、历史K线数据、财务指标、宏观经济数据等。采用Baostock作为数据源,无需付费账户。

Augur

BruceLanLan

Community

Augur is a local research memory system designed to help you remember when you knew what, what changed, and who disagreed on what facts. It is not an AI stock recommendation tool but a multi-agent investment analysis system with 18 investor persona agents, consensus mechanism, and multi-platform deployment. Requires Python 3.9+ (3.10+ for MCP features). External data files are stored locally in ~/.augur by default, configurable via the AUGUR_DATA_DIR environment variable.

Alpaca MCP Server

alpacahq

Community

用于 Alpaca 交易 API 的模型上下文协议(Model Context Protocol)服务器,支持大型语言模型(LLMs)与 Alpaca 的股票、期权、投资组合、观察列表和实时市场数据基础设施交互。需要通过环境变量(ALPACA_API_KEY、ALPACA_SECRET_KEY)配置的外部 API 密钥,通常在 .env 文件中设置。

FROM THE SOURCE

Repository README

Build-time snapshot · Retrieved 2026-10-05

View original

stock-api

支持 A 股、港股、美股行情查询的 TypeScript 股票数据工具。

English | 简体中文

Downloads Version License TypeScript

接口状态 腾讯状态 新浪状态 东方财富状态

在线体验 项目主页

stock-api 是一个零运行时依赖的股票行情工具,支持 Node.js、浏览器、CLI 和 MCP。默认使用 stocks.auto,自动从可用数据源获取行情。

支持使用方式

Node.js Browser CLI MCP

特性

  • Node.js / Browser bundler API + TypeScript 类型
  • CLI 查询股票行情、K 线和搜索股票
  • MCP tools 给 AI 客户端直接调用股票接口
  • 默认自动兜底:tencent -> sina -> eastmoney
  • 指定数据源:stocks.tencent / stocks.sina / stocks.eastmoney
  • 支持 A 股、港股、美股代码格式
  • 零运行时依赖

Node.js

安装

Node.js 环境要求 >=18。

npm install stock-api

使用

import { stocks } from "stock-api";

const stock = await stocks.auto.getStock("SH510500");
const list = await stocks.auto.getStocks(["SH510500", "SZ000651"]);
const klines = await stocks.auto.getKlines("SH600519", { period: "day" });
const results = await stocks.auto.searchStocks("格力电器");

股票代码使用 SH / SZ / HK / US 前缀,例如 SH510500、SZ000651。

浏览器

引用

<script src="https://cdn.jsdelivr.net/npm/stock-api/dist/browser/stock-api.iife.min.js"></script>

使用

<script>
  StockApi.stocks.auto.getStock("SH510500").then(console.log);
  StockApi.stocks.auto.getStocks(["SH510500", "SZ000651"]).then(console.log);
  StockApi.stocks.auto.getKlines("SH600519", { period: "day" }).then(console.log);
  StockApi.stocks.auto.searchStocks("格力电器").then(console.log);
</script>

浏览器示例:GitHub Pages

CLI

npx stock-api get-stock SH510500
npx stock-api get-stocks SH510500 SZ000651
npx stock-api get-klines SH600519 --period day --count 120
npx stock-api search-stocks 格力电器

MCP

把 stock-api 接到支持 MCP 的 AI 客户端:

{
  "mcpServers": {
    "stock-api": {
      "command": "npx",
      "args": ["-y", "stock-api", "mcp"]
    }
  }
}

内置工具:get_stock、get_stocks、get_klines、search_stocks、inspect_stock。

支持的 MCP 协议版本:2025-11-25、2025-06-18。握手时会返回客户端请求的版本,不支持则回退到最新的一个。

AI Agent(任意工具)

不想配置 MCP?把下面这句话发给任意 AI 工具(Claude Code、Codex、GLM 等),它读完就知道怎么用 stock-api:

请阅读 https://raw.githubusercontent.com/zhangxiangliang/stock-api/main/SKILL.md
然后用 stock-api 回答我的股票问题。

SKILL.md 里写了具体的 npx stock-api 命令,所以和 MCP 共用同一套数据逻辑,只是接入方式更简单、跨工具通用。

数据源

内置腾讯、新浪、东方财富数据源,默认由 stocks.auto 自动处理。

数据源 用法 能力
自动兜底 stocks.auto 单只行情、批量行情、K 线、搜索、诊断
腾讯 stocks.tencent 单只行情、批量行情、K 线、搜索、诊断
新浪 stocks.sina 单只行情、批量行情、K 线、搜索、诊断
东方财富 stocks.eastmoney A 股单只行情、批量行情、K 线、搜索、诊断

stocks.eastmoney.searchStocks 依赖的搜索接口对部分境外网络环境(例如海外服务器、CI 出口 IP)会返回反爬响应而失败,行情/K 线不受影响。直接依赖东方财富搜索的场景建议改用 stocks.auto,它会在东方财富搜索失败时自动回退到腾讯、新浪。

文档

文档 内容
API 使用 TypeScript API、自动兜底、诊断返回结构
CLI 使用 命令、参数、输出、退出码
项目架构 目录结构、provider 工厂、解析和错误模型
开发指南 本地开发、测试、发布前检查、新增数据源
API 监控 定时检查第三方数据源并更新状态徽章

免责声明

stock-api 使用第三方公开行情接口作为数据来源,不保证数据的准确性、完整性、实时性或持续可用性。本项目不提供投资建议,任何交易或投资决策都应由你自行判断。商业、高频或生产使用前,请自行确认第三方数据源的服务条款、授权范围和合规要求。

License

MIT