Data & analysis

TWSE API

Try it

Query Taiwan Stock Exchange (TWSE) open data via the official OpenAPI (https://openapi.twse.com.tw) — daily stock prices/OHLC, P/E ratio, dividend yield, P/B...

What it does

Query Taiwan Stock Exchange (TWSE) open data via the official OpenAPI (https://openapi.twse.com.tw) — daily stock prices/OHLC, P/E ratio, dividend yield, P/B, market index (TAIEX) history, company profiles and financial statements, monthly revenue, margin trading, block trades, ESG disclosures, warrants, broker data, and the trading calendar. Use this skill whenever the user asks about Taiwan stocks, 台股, 上市公司, TWSE/證交所 data, Taiwanese stock quotes or fundamentals, TAIEX/加權指數, or wants to fetch/analyze any Taiwan listed-company data, even if they don't mention the API by name.

The skill document

TWSE OpenAPI (Taiwan Stock Exchange 臺灣證券交易所)

Official open-data API of the Taiwan Stock Exchange. Free, no API key, no registration.

  • Base URL: https://openapi.twse.com.tw/v1
  • Method: all endpoints are plain GET, no parameters at all (no query string, no path params)
  • Response: always a JSON array of flat objects; every value is a string (numbers included)
  • Full endpoint catalog: 143 endpoints across 7 categories (see Endpoint catalog below)
  • Swagger spec: https://openapi.twse.com.tw/v1/swagger.json (docs UI: https://openapi.twse.com.tw/)

Critical conventions (read before calling)

  1. No server-side filtering. Each endpoint returns the entire dataset (typically the latest trading day's snapshot, or a historical series). To get data for one stock, fetch the whole array and filter client-side by stock code (Code or 公司代號). Responses range from a few rows to ~30,000 rows (insider-transfer tables), so filter with a script rather than dumping raw output into context.

  2. Two field-naming styles. Endpoints under /exchangeReport, /indicesReport, /announcement, /block, /fund, /holidaySchedule etc. mostly use English JSON keys (Code, Name, ClosingPrice…). Endpoints under /opendata (the t187ap* datasets) use Traditional Chinese JSON keys (公司代號, 公司名稱, 營業收入-當月營收…). The reference files list the exact keys per endpoint — use them verbatim; do not guess or translate key names.

  3. ROC (Minguo 民國) dates. Most Date/出表日期 values look like 1150706 = ROC year 115, July 6 = 2026-07-06 (Gregorian year = ROC year + 1911). Some fields (e.g. company founding date 成立日期) use Gregorian YYYYMMDD instead — check the magnitude: 7 digits starting with 1 is ROC, 8 digits starting with 19/20 is Gregorian.

  4. Snapshot data, not historical query. Most endpoints only expose the latest period: STOCK_DAY_ALL = latest trading day, FMSRFK_ALL = current month's aggregate (one row per stock), FMNPTK_ALL = current year's aggregate. There is no way to request an arbitrary past date through this API. True historical series exist only where noted (e.g. /indicesReport/MI_5MINS_HIST for TAIEX daily history).

  5. Number parsing. Numeric strings may contain commas ("1,030,726,137"), be empty, or be "-"/"-" for N/A. Strip commas and handle blanks before converting.

  6. Data scope is TWSE listed (上市) securities. OTC/TPEx (上櫃) securities are served by a different API (https://www.tpex.org.tw/openapi/), not this one. Endpoints suffixed _L = listed companies (上市), _P/_X = public non-listed companies (公開發行).

Quick start

# Daily OHLC for all listed stocks, filter for TSMC (2330)
curl -s https://openapi.twse.com.tw/v1/exchangeReport/STOCK_DAY_ALL |
  python3 -c "import json,sys; print([r for r in json.load(sys.stdin) if r['Code']=='2330'])"
import json, urllib.request

BASE = "https://openapi.twse.com.tw/v1"

def twse(path):
    with urllib.request.urlopen(BASE + path) as r:
        return json.load(r)

# P/E, dividend yield, P/B for one stock
row = next(r for r in twse("/exchangeReport/BWIBBU_ALL") if r["Code"] == "2330")
# {'Code': '2330', 'Name': '台積電', 'PEratio': '...', 'DividendYield': '...', 'PBratio': '...'}

# Company profile (Chinese keys!)
tsmc = next(r for r in twse("/opendata/t187ap03_L") if r["公司代號"] == "2330")

Task → endpoint cheat sheet

TaskEndpoint
Today's OHLC/volume, all stocks/exchangeReport/STOCK_DAY_ALL
P/E, dividend yield, P/B/exchangeReport/BWIBBU_ALL
Closing price + monthly average/exchangeReport/STOCK_DAY_AVG_ALL
Per-stock current-month / current-year aggregate/exchangeReport/FMSRFK_ALL / FMNPTK_ALL
TAIEX index history (daily OHLC)/indicesReport/MI_5MINS_HIST
Whole-market daily volume/value/exchangeReport/FMTQIK
Company basic profile/opendata/t187ap03_L
Monthly revenue, all companies/opendata/t187ap05_L
Income statement (general industry)/opendata/t187ap06_L_ci
Balance sheet (general industry)/opendata/t187ap07_L_ci
Dividend distributions/opendata/t187ap45_L
Material news / announcements/opendata/t187ap04_L
Ex-dividend calendar/exchangeReport/TWT48U_ALL
Margin trading balances/exchangeReport/MI_MARGN
Trading holidays / market calendar/holidaySchedule/holidaySchedule
TWSE news/news/newsList

Endpoint catalog

Read the reference file for the category you need — each lists every endpoint with its exact response keys (Chinese originals kept as comments):

Reference fileCategory (原分類)EndpointsContents
references/securities-trading.md證券交易36Daily quotes, valuation ratios, market stats, margin/block/day trading, attention & disposition stocks, market calendar
references/corporate-governance.md公司治理56Company profiles, insider/director holdings, board data, material news, dividends, shareholder meetings, 21 ESG datasets
references/financial-statements.md財務報表30Monthly revenue, income statements & balance sheets by industry format, profitability summaries
references/indices.md指數5TAIEX, Taiwan 50, Formosa Index histories
references/warrants.md權證3Warrant issuance and trading stats
references/brokers.md券商資料9Securities firm directories, personnel, monthly financials
references/misc.md其他4TWSE news/events, government bonds, funds

Related skills

Tonghuashun Financial Data (fuyao.aicubes.cn). Use this skill for ANY Tonghuashun Financial Data request — searching and reading data. Whenever a task involves Tonghuashun Financial Data, use this skill instead of calling the API directly.

Query Taiwan mutual fund NAV, performance, holdings via cnyes/MoneyDJ. Compare funds, auto currency conversion.

4 installs

Multi-market intelligent stock selection for A-share/HK/US stocks and ETFs. Use when user asks about stock analysis, market scanning, portfolio construction,...

Read A-share themes, sector flows, intraday board charts, limit-ups, and surveys.

Tushare (tushare.pro). Use this skill for ANY Tushare request — searching and reading data. Whenever a task involves Tushare, use this skill instead of calling the API directly.

Query real-time stock prices, basic quote fields, and manage a Markdown watchlist for A-share, Hong Kong, and US stocks. Use when users ask in Chinese or by...

34 installs