40 endpoints · Market Data · Fundamentals · Institutional Flow · Other · Sectors & Themes · Screener
https://api.blave.orgapi-key + secret-key headers on every requestAPI plan or Blave Agent planstock_id — TWSE (上市) / TPEx (上櫃) code, e.g. 2330, 0050, 00878, 006208. Letters and digits (dots allowed), ≤ 8 chars, else 400 {"error": "Invalid stock_id"}.start / end — YYYY-MM-DD, inclusive. Unless a block says otherwise they are not format-validated (filtering is a string comparison), so always send YYYY-MM-DD.503 {"error": "Upstream rate limit. Please retry shortly."} — retry later.batch/<data_type> (≤ 50 ids per call); never loop a single-stock endpoint over a universe./studio/market/twstock/list None.
data = requests.get(f"{BASE_URL}/studio/market/twstock/list" , headers=headers, timeout=60).json()["data"]# [{"stock_id": "00400A", "name": "主動國泰動能高息", "close": 14.72, "market": "TWSE",# "industry_code": None, "listing_date": None}, ...] # 2,392 rows in this response{"data": [...]}, ~2,400 rows (上市 + 上櫃, incl. ETFs; 興櫃 excluded).
| Field | Type | Description |
|---|---|---|
stock_id | string | Code |
name | string | Name |
close | float | null | Latest daily close (null when upstream had none, e.g. halted) |
market | string | TWSE (上市) or TPEx (上櫃) |
industry_code | string | null | TWSE/TPEx raw numeric 產業別 code, passthrough (not decoded). null for ETFs / non-company securities. Common codes: 15 航運業, 17 金融保險業, 22 生技醫療業, 24 半導體業, 25 電腦及週邊設備業, 26 光電業, 27 通信網路業, 28 電子零組件業, 29 電子通路業, 30 資訊服務業, 31 其他電子業 |
listing_date | string | null | YYYY-MM-DD; null for ETFs / non-company securities |
Shared errors only (500 if both markets fail).
[:N] truncation concentrates in a few sectors./studio/market/twstock/info/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions |
info = requests.get(f"{BASE_URL}/studio/market/twstock/info/2330" , headers=headers, timeout=30).json()["data"]# {"stock_id": "2330", "name": "台積電", "close": 2410.0, "industry_code": "24", "listing_date": "1994-09-05"}{"stock_id": "<stock_id>", "data": {...}}; data has the same fields as one /list row.
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid stock_id"} | Format check failed |
| 404 | {"error": "Stock not found"} | Not a currently listed security |
/list./studio/market/twstock/price/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Listed (上市) or OTC (上櫃) stock / ETF code | Letters/digits (dots allowed), ≤ 8 chars — e.g. 2330, 0050, 00878, 006208 | |
startstring · query | First date, inclusive | YYYY-MM-DD | full history |
endstring · query | Last date, inclusive | YYYY-MM-DD | latest available |
response = requests.get(f"{BASE_URL}/studio/market/twstock/price/2330" , headers=headers, timeout=60)data = response.json()["data"] # no start/end → full history, 8,069 rows# [{"date": "1994-10-01", "stock_id": "2330", "open": 171.0, "high": 172.0,# "low": 171.0, "close": 172.0, "spread": 1.0,# "volume": 1660506, "turnover_value": 284858008, "turnover_count": 684},# {"date": "1994-10-03", "stock_id": "2330", "open": 172.0, "high": 173.0,# "low": 171.0, "close": 172.0, "spread": 0.0,# "volume": 1560000, "turnover_value": 268084000, "turnover_count": 711}, ...]{"stock_id": "<stock_id>", "data": [ ... ]}, rows ascending by date.
| Field | Type | Unit | Description |
|---|---|---|---|
date | string | YYYY-MM-DD | Trading day |
stock_id | string | — | Stock code |
open / high / low / close | float | TWD | Unadjusted prices |
spread | float | TWD | Change vs the previous close |
volume | int | shares (股) | Trading volume |
turnover_value | int | TWD | Trading value |
turnover_count | int | trades (筆) | Number of trades |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid stock_id"} | stock_id fails the format check |
| 404 | {"error": "No data found for stock_id: <stock_id>"} | Unknown code / no data upstream |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted — retry later |
start / end are not format-validated: a malformed value filters by string comparison instead of returning 400, so always send YYYY-MM-DD.price_adj for backtesting total return; this endpoint is unadjusted.batch/price (≤ 50 ids per call) instead of looping this endpoint./studio/market/twstock/price_adj/<stock_id> Same as /price/<stock_id>.
params = {"start": "2020-01-01", "end": "2024-12-31"}data = requests.get(f"{BASE_URL}/studio/market/twstock/price_adj/2330" , headers=headers, params=params, timeout=60).json()["data"]Same shape and fields as /price/<stock_id>; open / high / low / close are adjusted, volume / turnover_* are identical to the raw series.
Same as /price/<stock_id>.
/price series advances./studio/market/twstock/quote/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions |
data = requests.get(f"{BASE_URL}/studio/market/twstock/quote/2330" , headers=headers, timeout=30).json()["data"]# {"open": 2415.0, "high": 2465.0, "low": 2415.0, "close": 2445.0,# "change_price": -20.0, "change_rate": -0.81, "average_price": 2432.58,# "volume": 4245, "total_volume": 26403, "amount": 10379025000, "total_amount": 64227410000,# "yesterday_volume": 27390, "buy_price": 2445.0, "buy_volume": 17,# "sell_price": 2450.0, "sell_volume": 11, "volume_ratio": 0.96,# "quote_time": "2026-07-03 14:30:00", "stock_id": "2330", "tick_type": 2}{"stock_id": "<stock_id>", "data": {...}}; data is a flat object.
| Field | Type | Description |
|---|---|---|
open / high / low / close | float | Today's OHLC so far |
change_price / change_rate | float | Change vs previous close (TWD / %) |
average_price | float | Average traded price |
volume | int | Latest tick's volume |
total_volume | int | Cumulative volume today |
amount / total_amount | float | Latest tick / cumulative traded value |
yesterday_volume | int | Previous day's volume |
buy_price / buy_volume | float / int | Best bid |
sell_price / sell_volume | float / int | Best ask |
volume_ratio | float | Volume ratio |
quote_time | string | YYYY-MM-DD HH:MM:SS — a full timestamp, unlike other endpoints' bare date |
stock_id | string | Code |
tick_type | int | 0 indeterminate, 1 sell-initiated (賣盤成交), 2 buy-initiated (買盤成交) |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid stock_id"} | Format check failed |
| 404 | {"error": "No data found for stock_id: <stock_id>"} | No quote |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
/studio/market/twstock/quote | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idsstring · queryRequired | Codes | Comma-separated, ≤ 50 ids |
data = requests.get(f"{BASE_URL}/studio/market/twstock/quote" , headers=headers, params={"stock_ids": "2330,2317"}, timeout=30).json()["data"]# {"2330": {...}, "2317": {...}}{"data": {"<stock_id>": {...quote fields...}, ...}}; fields as /quote/<stock_id>. Ids with no quote are absent.
| Status | Body | When |
|---|---|---|
| 400 | {"error": "stock_ids parameter required"} | Missing |
| 400 | {"error": "stock_ids exceeds max 50 per request"} | Too many |
| 400 | {"error": "Invalid stock_id in list"} | A code fails the format check |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
/studio/market/twstock/quote/all None.
rows = requests.get(f"{BASE_URL}/studio/market/twstock/quote/all" , headers=headers, timeout=30).json()["data"]{"data": [{...quote fields...}, ...]} (~2,800 rows); fields as /quote/<stock_id>.
| Status | Body | When |
|---|---|---|
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
/studio/market/twstock/minute/ohlcv/<stock_id>/<schema> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | A currently listed TWSE/TPEx code, or TAIEX (加權指數) | |
schemastring · pathRequired | Bar size | 1m, 5m, 15m, 30m, 60m, 1d | |
startstring · query | First day | YYYY-MM-DD | end − the schema's max range |
endstring · query | Last day, inclusive | YYYY-MM-DD | today (UTC) |
adjuststring · query | 1 = forward-adjusted (後復權) OHLC, same factors as /price_adj; volume is never adjusted | 0, 1, true, false | 0 |
Max range per request (end − start): 1m 31 d · 5m 62 d · 15m 93 d · 30m 186 d · 60m 365 d · 1d 3650 d.
body = requests.get(f"{BASE_URL}/studio/market/twstock/minute/ohlcv/2330/1m" , headers=headers, params={"start": "2026-08-06", "end": "2026-08-06"}, timeout=60).json()# {"stock_id": "2330", "schema": "1m", "data": [# {"close": 2385.0, "high": 2395.0, "low": 2385.0, "open": 2395.0, "ts": "2026-08-06 01:00:00+00:00", "volume": 2540}, ...]}{"stock_id", "schema", "data": [...]}.
| Field | Type | Unit | Description |
|---|---|---|---|
ts | string | UTC ISO | Bar open time (minute-start label); the 13:30 Taipei bar is the closing auction |
open / high / low / close | float | TWD | Prices |
volume | int | lots (張), not shares | Volume. TAIEX bars always carry volume: 0 at every schema — the index has no volume, so none is served; do not read it as a turnover figure |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid stock_id (must be a listed TWSE/TPEx security)"} | Not listed |
| 400 | {"error": "Invalid schema. Allowed: [...]"} | Bad schema |
| 400 | {"error": "Invalid adjust (use 0 or 1)"} | Bad adjust |
| 400 | {"error": "Invalid date format. Use YYYY-MM-DD"} | Malformed date |
| 400 | {"error": "date_range_too_large", "message": "...", "max_days": <n>} | Range over the cap |
| 503 | {"error": "market data temporarily unavailable"} | Store read failure |
| 503 | {"error": "adjust factors temporarily unavailable"} | adjust=1 and factors unavailable — never silently served unadjusted |
minute/ohlcv/symbols before requesting years of history.200 with []./quote/<stock_id> for the live price./studio/market/twstock/minute/ohlcv/symbols None.
covered = requests.get(f"{BASE_URL}/studio/market/twstock/minute/ohlcv/symbols" , headers=headers, timeout=30).json()["data"]{"data": ["2330", "TAIEX", ...]} — ids that already have minute-line data on disk (currently listed stocks plus TAIEX), sorted.
Shared errors only.
/studio/market/twstock/kbar/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | A currently listed TWSE/TPEx code, or TAIEX | |
startstring · query | First day | YYYY-MM-DD | today − 6 days |
endstring · query | Last day; end − start ≤ 31 days | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twstock/kbar/2330" , headers=headers, params={"start": "2026-08-03", "end": "2026-08-07"}, timeout=60).json()["data"]{"stock_id", "data": [...]}, ascending.
| Field | Type | Description |
|---|---|---|
date | string | YYYY-MM-DD (Taipei) |
minute | string | HH:MM:SS Taipei, bar start (09:00–13:30) |
stock_id | string | Code |
open / high / low / close | float | TWD |
volume | int | Lots (張) |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid stock_id (must be a listed TWSE/TPEx security)"} | Not listed |
| 400 | {"error": "Date range exceeds 31 days"} | Range too long |
| 400 | {"error": "Invalid start date, expected YYYY-MM-DD"} (or end) | Malformed date |
| 400 | {"error": "start must not be after end"} | Reversed range |
minute/ohlcv/<stock_id>/1m. A listed stock with no minute data returns [] (this endpoint does not trigger seeding).minute/ohlcv/symbols have data./studio/market/twstock/market_value/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First date | YYYY-MM-DD | full history |
endstring · query | Last date | YYYY-MM-DD | latest |
data = requests.get(f"{BASE_URL}/studio/market/twstock/market_value/2330" , headers=headers, params={"start": "2026-01-01"}, timeout=60).json()["data"]{"stock_id", "data": [{"date", "stock_id", "market_value"}]}; market_value in TWD.
400 invalid stock_id, 404 no data, 503 upstream quota.
/studio/market/twstock/market_value/all | Name | Description | Allowed | Default |
|---|---|---|---|
topint · query | Keep only the top N by market value | 1–3000 | all (~2,400) |
body = requests.get(f"{BASE_URL}/studio/market/twstock/market_value/all" , headers=headers, params={"top": 10}, timeout=60).json()# {"date": "2026-09-17", "twse_ex_etf_market_value": 150952470507848,# "data": [{"is_etf": false, "market": "TWSE", "market_value": 62885997412475,# "name": "台積電", "rank": 1, "stock_id": "2330"},# ...,# {"is_etf": true, "market": "TWSE", "market_value": 2383312875000,# "name": "元大台灣50", "rank": 6, "stock_id": "0050"}, ...]}# Index weight of a 上市 non-ETF stock (works with any `top`, the denominator is whole-market)row = body["data"][0] # 2330 — market "TWSE", is_etf falseshare = row["market_value"] / body["twse_ex_etf_market_value"]# ETFs rank alongside stocks (0050 is rank 6) — filter them with `is_etf`. Never by code prefix,# and never by re-fetching a classification: `is_etf` already IS that classification.rows = requests.get(f"{BASE_URL}/studio/market/twstock/market_value/all" , headers=headers, params={"top": 100}, timeout=60).json()["data"]top50 = [r["stock_id"] for r in rows if not r["is_etf"]][:50] # ETF-free market-cap top 50tpex_only = [r["stock_id"] for r in rows if r["market"] == "TPEx"] # board filter is exact{"date": "YYYY-MM-DD", "twse_ex_etf_market_value": int, "data": [...]}, sorted by market value descending.
| Field | Type | Description |
|---|---|---|
date | string | As-of day actually used (latest published; can lag today by a day) |
twse_ex_etf_market_value | int | TWD. Sum of the market == "TWSE" rows that are not ETFs, on the same as-of day. Whole-market denominator — not reduced by top |
data[].rank | int | 1-based rank |
data[].stock_id | string | Code |
data[].name | string | Name |
data[].market | string | "TWSE" (上市) or "TPEx" (上櫃), from the TWSE / TPEx listing rosters |
data[].market_value | int | TWD |
data[].is_etf | bool | true for the ETFs in the ranking (359 of 2,370 rows on 2026-09-17). false means "not in the ETF set", not "confirmed not an ETF": a security with no industry category — e.g. REIT 01010T — is false, and it stays inside twse_ex_etf_market_value |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "top must be an integer between 1 and 3000"} | Bad top |
| 503 | {"error": "Data temporarily unavailable. Please retry shortly."} | Recent data or the listing is temporarily unavailable |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
/market_value/<stock_id> for "top N by market cap" questions.rank and twse_ex_etf_market_value are different universes. rank is whole-market — 上市 + 上櫃, ETFs included — and did not change when the denominator was added. The denominator is 上市 only and excludes ETFs (industry_category in {ETF, 上櫃ETF, 上櫃指數股票型基金(ETF)}); REITs and preferred shares are not excluded from it. So market_value / twse_ex_etf_market_value is an index weight only for a row whose market is "TWSE" and which is not an ETF — a TPEx or ETF row over this denominator is not a weight — while rank stays a whole-market rank. Don't read the two as one ranking.market is a listing-board tag, not an ETF flag — is_etf is the ETF flag. Use it for an ETF-free universe. Don't infer ETFs from the stock_id prefix (00 is a market convention rather than a contract, and it misses REITs 01xxxT) and don't re-fetch a classification from elsewhere. is_etf is exactly the criterion twse_ex_etf_market_value is computed on, so an is_etf filter and the denominator can never disagree./studio/market/twstock/per/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First date | YYYY-MM-DD | full history |
endstring · query | Last date | YYYY-MM-DD | latest |
data = requests.get(f"{BASE_URL}/studio/market/twstock/per/2330" , headers=headers, params={"start": "2026-01-01", "end": "2026-07-22"}, timeout=60).json()["data"]# [{"date": "2026-07-21", "stock_id": "2330", "dividend_yield": 0.95, "PER": 34.87, "PBR": 11.05}, ...]{"stock_id", "data": [...]}.
| Field | Type | Description |
|---|---|---|
date | string | Trading day |
stock_id | string | Code |
dividend_yield | float | Dividend yield (%) |
PER | float | Price / earnings |
PBR | float | Price / book |
400 invalid stock_id, 404 no data, 503 upstream quota.
batch/per./studio/market/twstock/financials/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First date | YYYY-MM-DD | 2013-01-01 |
endstring · query | Last date | YYYY-MM-DD | today |
import pandas as pddata = requests.get(f"{BASE_URL}/studio/market/twstock/financials/2330" , headers=headers, params={"start": "2022-01-01", "end": "2024-12-31"}, timeout=30).json()["data"]# [{"date": "2022-03-31", "stock_id": "2330", "type": "Revenue", "value": 491075000000.0, "origin_name": "營業收入"}, ...]wide = pd.DataFrame(data).pivot_table(index="date", columns="type", values="value", aggfunc="first"){"stock_id", "data": [...]}, long format (one row per item per quarter).
| Field | Type | Description |
|---|---|---|
date | string | Quarter end (03-31 / 06-30 / 09-30 / 12-31) |
stock_id | string | Code |
type | string | Item code, e.g. Revenue, GrossProfit, OperatingIncome, NetIncome, EPS, TAX, OtherComprehensiveIncome |
value | float | Value (TWD; EPS in TWD per share) |
origin_name | string | Chinese label — use it to identify unfamiliar type codes |
400 invalid stock_id, 404 no data, 503 upstream quota.
start defaults to 2013-01-01; send an earlier start and earlier rows come back (2330 goes back to 2000-06-30)./studio/market/twstock/balance_sheet/<stock_id> Same as /financials/<stock_id>.
data = requests.get(f"{BASE_URL}/studio/market/twstock/balance_sheet/2330" , headers=headers, params={"start": "2022-01-01"}, timeout=30).json()["data"]Same long format as /financials/<stock_id>. Key type codes: CashAndCashEquivalents, TotalAssets, TotalLiabilities, TotalEquity. Codes ending in _per are % of total assets.
400 invalid stock_id, 404 no data, 503 upstream quota.
start defaults to 2013-01-01; send an earlier start and earlier rows come back (2330 goes back to 2012-12-31)./studio/market/twstock/cashflow/<stock_id> Same as /financials/<stock_id>.
import pandas as pddata = requests.get(f"{BASE_URL}/studio/market/twstock/cashflow/2330" , headers=headers, params={"start": "2022-01-01"}, timeout=30).json()["data"]cfo = (pd.DataFrame(data).query("type == 'CashFlowsFromOperatingActivities'") .assign(date=lambda d: pd.to_datetime(d["date"])).set_index("date")["value"].sort_index())cfo_q = cfo - cfo.groupby(cfo.index.year).shift(1).fillna(0) # YTD → single quarterSame long format as /financials/<stock_id>. Main type codes (the upstream dataset's own codes; the full set varies by company and year, so treat the response as the authoritative list and use origin_name for anything not below). Filter on type, not origin_name — the same code's label switches between full- and half-width brackets across years:
type | origin_name |
|---|---|
CashFlowsFromOperatingActivities | 營業活動之淨現金流入(流出) |
CashProvidedByInvestingActivities | 投資活動之淨現金流入(流出) |
CashFlowsProvidedFromFinancingActivities | 籌資活動之淨現金流入(流出) |
PropertyAndPlantAndEquipment | 取得不動產、廠房及設備 (capex, negative) |
Depreciation / AmortizationExpense | 折舊費用 / 攤銷費用 |
CashBalancesIncrease | 本期現金及約當現金增加(減少)數 |
CashBalancesBeginningOfPeriod / CashBalancesEndOfPeriod | 期初(年初)/ 期末現金及約當現金餘額 |
Flow items are year-to-date (YTD) cumulative, as filed in Taiwan: the 03-31 row is Q1 alone, 06-30 is Q1–Q2, 09-30 is Q1–Q3, 12-31 is the full year. For a single quarter subtract the previous quarter of the same year (Q1 needs no subtraction) — so fetch from a January start. CashBalancesEndOfPeriod is the balance at the quarter end; CashBalancesBeginningOfPeriod is the balance at the start of the year. This endpoint has no period parameter — it always returns YTD (the ?period=quarter single-quarter view exists only on the web chart route, not here).
400 invalid stock_id, 404 no data, 503 upstream quota.
start defaults to 2013-01-01; send an earlier start and earlier rows come back (2330 goes back to 2012-03-31)./studio/market/twstock/monthly_revenue/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First date | YYYY-MM-DD | 2000-01-01 |
endstring · query | Last date | YYYY-MM-DD | today |
import pandas as pddata = requests.get(f"{BASE_URL}/studio/market/twstock/monthly_revenue/2330" , headers=headers, params={"start": "2024-01-01", "end": "2024-12-31"}, timeout=30).json()["data"]df = pd.DataFrame(data).sort_values(["revenue_year", "revenue_month"])df["yoy_pct"] = df["revenue"].pct_change(periods=12) * 100# [{"date": "2024-01-01", "stock_id": "2330", "country": "Taiwan", "create_time": "",# "revenue": 176299866000, "revenue_year": 2023, "revenue_month": 12},# {"date": "2024-02-01", "stock_id": "2330", "country": "Taiwan", "create_time": "",# "revenue": 215785127000, "revenue_year": 2024, "revenue_month": 1}, ...]{"stock_id", "data": [...]}, one row per month.
| Field | Type | Description |
|---|---|---|
date | string | First day of the month after the revenue month — 2024-01-01 carries revenue_year: 2023, revenue_month: 12. Never use it as the period |
stock_id | string | Code |
country | string | Market — observed value is Taiwan |
create_time | string | Observed empty ("") on every row |
revenue | int | Monthly revenue in TWD (元), not thousands — inferred from magnitude, not stated upstream: 2330 for revenue_year 2024, revenue_month 1 returned 215785127000, which is only a sane figure read as 元 (NT$215.8bn) |
revenue_month | int | Revenue month (1–12) — use this, not date, for the period |
revenue_year | int | Revenue year |
400 invalid stock_id, 404 no data, 503 upstream quota.
/studio/market/twstock/ratios/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First quarter-end date | YYYY-MM-DD | 2013-01-01 |
endstring · query | Last quarter-end date | YYYY-MM-DD | today |
import pandas as pddata = requests.get(f"{BASE_URL}/studio/market/twstock/ratios/2330" , headers=headers, params={"start": "2024-01-01"}, timeout=30).json()["data"]# [..., {"date": "2026-06-30", "stock_id": "2330",# "gross_margin_q": 67.7207, "gross_margin_ttm": 64.2302, "operating_margin_q": 60.3443, "operating_margin_ttm": 56.1009,# "net_margin_q": 55.6354, "net_margin_ttm": 50.3717, "roe_q": 11.3934, "roe_ttm": 40.3342, "roa_q": 7.8372, "roa_ttm": 27.3074,# "eps_q": 27.25, "eps_ttm": 86.28, "eps_yoy_q": 77.4089, "eps_yoy_ttm": 53.2232,# "revenue_yoy_q": 36.0453, "revenue_yoy_ttm": 30.5567, "revenue_qoq_q": 12.0163, "revenue_qoq_ttm": 8.2017,# "debt_ratio": 30.9438, "current_ratio": 245.7635, "quick_ratio": 225.0114, "equity_multiplier": 1.4481,# "interest_coverage_q": 280.5515, "interest_coverage_ttm": 227.0232,# "inventory_turnover_q": 1.1767, "inventory_turnover_ttm": 4.6058, "cfo_to_net_income_q": 1.1084, "cfo_to_net_income_ttm": 1.1779,# "fcf_q": 287363030000.0, "fcf_ttm": 1143556366000.0, "fcf_per_share_q": 11.0827, "fcf_per_share_ttm": 44.1036, ...}]df = pd.DataFrame(data).assign(date=lambda d: pd.to_datetime(d["date"])).set_index("date"){"stock_id", "data": [...]}, wide format: one row per quarter, oldest first, one column per ratio. Every ratio is a float rounded to 4 decimals, or null.
| Field | Type | Description |
|---|---|---|
date | string | Quarter end (03-31 / 06-30 / 09-30 / 12-31) — not the day the filing became public |
stock_id | string | Code |
<ratio>_q | float | null | The quarter alone |
<ratio>_ttm | float | null | Trailing four quarters (the four single quarters summed); null if any of the four is missing |
debt_ratio, current_ratio, quick_ratio, equity_multiplier | float | null | Period-end balance-sheet ratios — no suffix |
<ratio> (each has both _q and _ttm):
| Group | Ratios | Unit |
|---|---|---|
| Profitability | gross_margin, operating_margin, pretax_margin, net_margin, opex_ratio, roe, roa | % (already ×100) |
| Per share | eps, revenue_per_share, fcf_per_share | TWD per share |
| Growth | revenue_yoy, revenue_qoq, operating_income_yoy, net_income_yoy, eps_yoy | % (already ×100) |
| Structure | interest_coverage | times |
| Efficiency | receivable_turnover, inventory_turnover, asset_turnover, cfo_to_net_income | times |
| Cash flow | fcf | TWD, raw amount (not thousands) |
No-suffix columns: debt_ratio, current_ratio, quick_ratio are % (already ×100 — a current ratio of 2.46× comes back as 245.7635); equity_multiplier is times.
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid stock_id"} | Code fails the format check |
| 404 | {"error": "No data found for stock_id: <id>"} | No financial statements for the code (ETFs such as 0050 / 00878), or no row inside start–end |
| 503 | {"error": "Data temporarily unavailable. Please retry shortly."} | Ratio store not ready — retry later, never read it as "no data" |
null (no gross margin, current ratio, etc.).date is lookahead.null, never 0.per/<stock_id>) and the monthly-revenue ratios (compute YoY / MoM from monthly_revenue/<stock_id>).GET /studio/market/twstock/batch/ratios?stock_ids=... (≤ 50 ids per call).start returns nothing older./studio/market/twstock/dividend/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | Currently listed code (4–6 digits, optional trailing letter) | |
startstring · query | First effective date | strict YYYY-MM-DD | full history |
endstring · query | Last effective date | strict YYYY-MM-DD | full history |
Range filtering uses a three-tier effective date: cash_ex_date if set, else stock_ex_date, else record_date — freshly announced events without an ex date still show up.
data = requests.get(f"{BASE_URL}/studio/market/twstock/dividend/2330" , headers=headers, params={"start": "2025-01-01", "end": "2025-12-31"}, timeout=30).json()["data"]# [{"record_date": "2025-03-24", "period": "113年第3季", "announce_date": "2025-03-03",# "cash_ex_date": "2025-03-18", "stock_ex_date": "", "pay_date": "2025-04-10",# "cash": 4.50002042, "stock": 0.0, "stock_ratio": 0.0}, ...]{"stock_id", "data": [...]}, one row per announcement row.
| Field | Type | Description |
|---|---|---|
record_date | string | 權利分派基準日 YYYY-MM-DD |
period | string | 股利所屬期間 — an opaque label (114年第3季, 113, 不適用, …); compare as string, do not parse into a year |
announce_date | string | 公告日; "" when unknown |
cash_ex_date | string | 除息交易日; "" when none / not decided |
stock_ex_date | string | 除權交易日; "" when none |
pay_date | string | 現金股利發放日; "" when unknown |
cash | float | Cash dividend per share (TWD, 盈餘 + 公積) |
stock | float | Stock dividend per share (元面額, 盈餘 + 公積) |
stock_ratio | float | stock / 10 — split-style adjustment ratio |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid stock_id"} | Format check failed |
| 400 | {"error": "Invalid start date, expected YYYY-MM-DD"} (or end) | Malformed date |
| 404 | {"error": "No data found for stock_id: <id>"} / {"error": "No dividend records for stock_id: <id>"} | Not listed, or no dividend history at all |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
cash == 0 and stock == 0) are kept — an announced no-distribution decision.2330 full-history call ran to a date a week ahead of the request. Filter by date yourself if you need past events only.200 + [] (distinct from 404).404./studio/market/twstock/news/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First day | YYYY-MM-DD | today − 6 days |
endstring · query | Last day; end − start ≤ 31 days | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twstock/news/2330" , headers=headers, params={"start": "2026-08-01", "end": "2026-08-07"}, timeout=60).json()["data"]{"stock_id", "data": [...]}, several articles per day (weekends included).
| Field | Type | Description |
|---|---|---|
date | string | Publish datetime |
stock_id | string | Code |
title | string | Headline |
source | string | Publisher |
link | string | URL |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Date range exceeds 31 days"} or a date-parse message | Range too long / malformed date |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
[]./studio/market/twstock/institutional/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First date | YYYY-MM-DD | full history |
endstring · query | Last date | YYYY-MM-DD | latest |
data = requests.get(f"{BASE_URL}/studio/market/twstock/institutional/2330" , headers=headers, params={"start": "2024-01-01", "end": "2024-12-31"}, timeout=60).json()["data"]# [{"date": "2024-01-02", "stock_id": "2330", "foreign_buy": 28464159, "foreign_sell": 47404324,# "trust_buy": 5553520, "trust_sell": 269712, "dealer_self_buy": 452000, "dealer_self_sell": 366190,# "dealer_hedge_buy": 942546, "dealer_hedge_sell": 780090,# "foreign_dealer_self_buy": 0, "foreign_dealer_self_sell": 0}, ...]{"stock_id", "data": [...]}, wide format, one row per day. All values in shares (股).
| Field | Description |
|---|---|
date, stock_id | Day, code |
foreign_buy / foreign_sell | 外資 (excl. foreign dealers) |
trust_buy / trust_sell | 投信 |
dealer_self_buy / dealer_self_sell | 自營商自行買賣 |
dealer_hedge_buy / dealer_hedge_sell | 自營商避險 |
foreign_dealer_self_buy / foreign_dealer_self_sell | 外資自營商 (mostly 0) |
400 invalid stock_id, 404 no data, 503 upstream quota.
*_buy − *_sell.GET /studio/market/twmarket/institutional) groups it differently — see that section./studio/market/twstock/margin/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First date | YYYY-MM-DD | full history |
endstring · query | Last date | YYYY-MM-DD | latest |
import pandas as pddata = requests.get(f"{BASE_URL}/studio/market/twstock/margin/2330" , headers=headers, params={"start": "2024-01-01"}, timeout=60).json()["data"]df = pd.DataFrame(data)df["margin_util"] = df["margin_balance"] / df["margin_limit"] # 融資使用率{"stock_id", "data": [...]}, one row per day. Values are lots (張), not shares — verified against TWSE MI_MARGN: for 2026-09-15 2330 returned margin_balance: 29282 and margin_limit: 6483092, matching TWSE's own 今日餘額 29,282 and 次一營業日限額 6,483,092 for that date exactly. Every row carries its own date and stock_id; when reading full history (no start / end) take every figure from the same row — margin_limit is re-published per day and changes over time.
| Field | Description |
|---|---|
margin_buy / margin_sell | 融資買進 / 賣出 |
margin_cash_repay | 融資現金償還 |
margin_balance / margin_prev_balance | 融資今日 / 前日餘額 |
margin_limit | 融資限額 — TWSE's 次一營業日限額 as published on that row's date, i.e. the cap that applies to the NEXT business day (2330 on 2026-09-15: 6,483,092 lots) |
short_buy / short_sell | 融券買進 / 賣出 |
short_cash_repay | 融券現金償還 |
short_balance / short_prev_balance | 融券今日 / 前日餘額 |
short_limit | 融券限額 |
offset_loan_short | 資券相抵 |
400 invalid stock_id, 404 no data, 503 upstream quota.
/studio/market/twstock/gov_bank/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First day | YYYY-MM-DD | today − 6 days |
endstring · query | Last day; end − start ≤ 31 days | YYYY-MM-DD | today |
data = requests.get(f"{BASE_URL}/studio/market/twstock/gov_bank/2330" , headers=headers, params={"start": "2026-08-01", "end": "2026-08-07"}, timeout=60).json()["data"]{"stock_id", "data": [...]}, up to 8 rows per day (one per bank), sorted by date, bank.
| Field | Description |
|---|---|
date, stock_id | Day, code |
bank_name | Bank |
buy / sell | Shares bought / sold |
buy_amount / sell_amount | TWD bought / sold |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Date range exceeds 31 days"} or a date-parse message | Range too long / malformed date |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
/studio/market/twstock/lending/<stock_id> | Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
startstring · query | First date | YYYY-MM-DD | full history |
endstring · query | Last date | YYYY-MM-DD | latest |
data = requests.get(f"{BASE_URL}/studio/market/twstock/lending/2330" , headers=headers, params={"start": "2026-08-01"}, timeout=60).json()["data"]{"stock_id", "data": [...]}, several rows per day.
| Field | Description |
|---|---|
date, stock_id | Day, code |
transaction_type | 競價 / 議借 |
volume | Volume |
fee_rate | Lending fee rate |
close | Close price |
original_return_date | Original return date |
original_lending_period | Original lending period |
400 invalid stock_id, 404 no data, 503 upstream quota.
/studio/market/twstock/broker/search | Name | Description | Allowed | Default |
|---|---|---|---|
namestring · queryRequired | Branch name to search | Any substring, case-insensitive |
rows = requests.get(f"{BASE_URL}/studio/market/twstock/broker/search" , headers=headers, params={"name": "松山"}, timeout=30).json()["data"]# [{"broker_id": "9217", "broker_name": "凱基-松山"}, ...]{"query": "<name>", "data": [{"broker_id", "broker_name"}]}.
| Status | Body | When |
|---|---|---|
| 400 | {"error": "name parameter required"} | Missing |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
/studio/market/twstock/broker/stock/<stock_id> Send date for one day, or start (+ end) for a range; start wins if both are sent.
| Name | Description | Allowed | Default |
|---|---|---|---|
stock_idstring · pathRequired | Code | See category conventions | |
datestring · query | Single day | YYYY-MM-DD | today |
startstring · query | Range start | YYYY-MM-DD | |
endstring · query | Range end; range ≤ 366 days inclusive | YYYY-MM-DD | start |
rows = requests.get(f"{BASE_URL}/studio/market/twstock/broker/stock/2330" , headers=headers, params={"start": "2026-08-03", "end": "2026-08-07"}, timeout=60).json()["data"]{"stock_id", "data": [...]}, one row per branch per day.
| Field | Type | Description |
|---|---|---|
date | string | Trading day |
stock_id | string | Code |
broker_id | string | Branch code (may be alphanumeric, e.g. 920A) |
broker_name | string | Branch name |
price | float | Volume-weighted average traded price |
buy / sell | int | Shares bought / sold |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid stock_id"} | Format check failed |
| 400 | {"error": "Invalid date (YYYY-MM-DD)"} | Malformed date |
| 400 | {"error": "start/end range is <n> days; max 366 (inclusive) — split into smaller ranges"} | Range too long |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Data temporarily unavailable — retry; do not read as "no trades" |
200 + [].start / end over 2026-09-06 → 2026-09-13 returned rows spanning five distinct trading days, for both broker/stock/<stock_id> and broker/trader/<trader_id>./studio/market/twstock/broker/trader/<trader_id> Same date / start / end rules as /broker/stock/<stock_id>.
| Name | Description | Allowed | Default |
|---|---|---|---|
trader_idstring · pathRequired | Branch code from /broker/search | Letters, digits, - (e.g. 9217, 920A) | |
datestring · query | Single day | YYYY-MM-DD | today |
startstring · query | Range start | YYYY-MM-DD | |
endstring · query | Range end; range ≤ 366 days inclusive | YYYY-MM-DD | start |
rows = requests.get(f"{BASE_URL}/studio/market/twstock/broker/trader/9217" , headers=headers, params={"date": "2026-08-07"}, timeout=60).json()["data"]{"trader_id", "data": [...]}, one row per stock per day; fields date, broker_id, broker_name, stock_id, price, buy, sell (as /broker/stock).
As /broker/stock/<stock_id>, with 400 {"error": "Invalid trader_id"} for a bad code.
/studio/market/twstock/alerts Give date, or start / end, or neither (= today, Taipei).
| Name | Description | Allowed | Default |
|---|---|---|---|
datestring · query | One day: disposals in force that day, notices announced that day | strict YYYY-MM-DD; not with start / end | |
startstring · query | First day of the range | strict YYYY-MM-DD | 2001-01-01 with stock_id, else end − 365 days |
endstring · query | Last day of the range (inclusive) | strict YYYY-MM-DD | today (or start if later) |
kindstring · query | Announcement type | disposal (處置), notice (注意) | both |
marketstring · query | Exchange | twse, tpex | both |
stock_idstring · query | One code; lifts the 366-day cap | See category conventions | all |
Range semantics: a disposal is returned when its period (start–end) overlaps the range, a notice when its announcement date is inside it. Without stock_id the range is at most 366 days inclusive — split longer whole-market ranges (one calendar year per call fits). Unlike the category default, start / end / date are strictly validated.
# disposals in force on one daydata = requests.get(f"{BASE_URL}/studio/market/twstock/alerts" , headers=headers, params={"date": "2026-10-13", "kind": "disposal"}, timeout=30).json()["data"]# [..., {"date": "2026-10-12", "stock_id": "5228", "stock_name": "鈺鎧", "market": "tpex",# "kind": "disposal", "count": 2, "start": "2026-10-13", "end": "2026-10-19",# "condition": "連續3個營業日", "measure": "第一次處置", "match_minutes": 2,# "reason": "* 公布日期:115/10/12\n* 證券代號:5228\n…", "close": 59.6, "pe": 29.22},# {"date": "2026-10-12", "stock_id": "2492", "stock_name": "華新科", "market": "twse",# "kind": "disposal", "count": 8, "start": "2026-10-13", "end": "2026-10-19",# "condition": "連續三次", "measure": "第一次處置", "match_minutes": 2,# "reason": "1處置原因:該有價證券之交易,連續三個營業日達本公司「公布注意交易資訊」標準。\n2處置期間:…", "close": None, "pe": None}, ...] # 36 rows# notices announced on one daynotes = requests.get(f"{BASE_URL}/studio/market/twstock/alerts" , headers=headers, params={"date": "2026-10-12", "kind": "notice"}, timeout=30).json()["data"]# [..., {"date": "2026-10-12", "stock_id": "5228", "stock_name": "鈺鎧", "market": "tpex",# "kind": "notice", "count": 15, "start": None, "end": None, "condition": "第一款、第三款、第四款",# "measure": None, "match_minutes": None,# "reason": "最近六個營業日(含當日)累積之最後成交價漲幅達32.63%(第一款)\n…", "close": 59.6, "pe": 29.22}, ...]# one stock's disposal history (no range cap with stock_id)hist = requests.get(f"{BASE_URL}/studio/market/twstock/alerts" , headers=headers, params={"stock_id": "2492", "kind": "disposal", "start": "2001-01-01"}, timeout=30).json()["data"]# 10 rows: 2001-11-23~2001-11-29 收足五成款券 (match_minutes None), 2018-05-08~2018-05-21 第一次處置 (5), …,# 2026-10-13~2026-10-19 第一次處置 (2){"start", "end", "data": [...]}; start / end echo the resolved range (both equal date when date was sent). Rows sorted by date, market, kind, stock_id. One row per announcement.
| Field | Type | Description |
|---|---|---|
date | string | Announcement day YYYY-MM-DD (a disposal takes effect the next trading day) |
stock_id | string | Code — includes warrants, ETFs and convertible bonds (e.g. 037060, 45402) |
stock_name | string | null | Name as published |
market | string | twse (上市) or tpex (上櫃) |
kind | string | disposal or notice |
count | int | The exchange's cumulative count (累計 / 累計次數) |
start, end | string | null | Disposal period, both days included; null on notices |
condition | string | null | Disposal: the trigger as published (連續三次, 連續3個營業日, 最近十個營業日已有六次 …). Notice: the clauses cited (第一款、第五款); null if none |
measure | string | null | Disposal type: 第一次處置, 第二次處置, 再次處置, 人工管制撮合, 收足五成款券 …; null on notices and on early TPEx rows |
match_minutes | int | null | Disposal: N of 「約每N分鐘撮合一次」 read from the text; null when the text names none (every TWSE disposal before ~2011 — its text is blank — and non-matching measures) and on notices |
reason | string | null | Full announcement text; null where the exchange published none (every TWSE disposal before 2011-03) (disposal 處置內容, notice 注意交易資訊) |
close, pe | float | null | Close and P/E on the announcement; always null on TWSE disposals |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "Invalid start date, expected YYYY-MM-DD"} (or end) | Malformed start / end |
| 400 | {"error": "start must not be after end"} | Reversed range |
| 400 | {"error": "Invalid date, expected YYYY-MM-DD"} | Malformed date |
| 400 | {"error": "use either date or start/end"} | date sent with start or end |
| 400 | {"error": "Invalid stock_id"} | Format check failed |
| 400 | {"error": "kind must be one of ['disposal', 'notice']"} / {"error": "market must be one of ['twse', 'tpex']"} | Unknown value |
| 400 | {"error": "start/end range is <n> days; max 366 (inclusive) without stock_id — split into smaller ranges"} | Range over 366 days without stock_id |
| 503 | {"error": "Data temporarily unavailable. Please retry shortly."} | A table you asked for is not servable (not refreshed for 48 h, or unreadable) — retry later, never read it as "no announcements". Only the requested kind / market tables are checked |
date is the announcement day, start the first day in force. To ask "under disposition on D", use date=D (or start=end=D), not the announcement date.start / end are the announced period; a market holiday or trading suspension inside it extends the real end, which the data does not record.match_minutes follows the rules of the day (TPEx 5 / 20 minutes → 2 from 2026-08-10) — read it per row, never assume a value./studio/market/twstock/batch/<data_type> | Name | Description | Allowed | Default |
|---|---|---|---|
data_typestring · pathRequired | Dataset | price, price_adj, per, institutional, shareholding, foreign_shareholding, financials, balance_sheet, monthly_revenue, ratios, dividend | |
stock_idsstring · queryRequired | Codes | Comma-separated, ≤ 50 | |
startstring · query | First date | YYYY-MM-DD (strictly validated for dividend only) | per data_type |
endstring · query | Last date | YYYY-MM-DD | per data_type |
payload = requests.get(f"{BASE_URL}/studio/market/twstock/batch/per" , headers=headers, params={"stock_ids": "2330,6182", "start": "2026-08-04", "end": "2026-08-08"}, timeout=120).json()# {"data_type": "per",# "data": {"2330": [{"date": "2026-08-04", "dividend_yield": 0.95, "PER": 31.19, "PBR": 10.21, "stock_id": "2330"}, ...],# "6182": [...]},# "failed": []}{"data_type", "data": {"<stock_id>": [...rows...]}, "failed": [...]}. Rows are identical to the matching single-stock endpoint.
failed — ids whose server-side fetch failed (rate limit or upstream error); retry those.data and failed genuinely has no data.| Status | Body | When |
|---|---|---|
| 400 | {"error": "Unsupported data_type '<x>'. Supported: [...]"} | Bad data_type |
| 400 | {"error": "stock_ids parameter required"} | Missing |
| 400 | {"error": "stock_ids exceeds max 50 per request"} | Too many |
| 400 | {"error": "Invalid stock_id in list"} | A code fails the format check |
| 400 | {"error": "Invalid start date, expected YYYY-MM-DD"} | dividend only |
ratios (財務比率): each id's rows are the wide per-quarter rows of /ratios/<stock_id> ("data": {"2330": [{"date": "2026-06-30", "stock_id": "2330", "roe_q": 11.3934, ...}], "2317": [...]}). A code with no financial statements (ETFs) is absent from both data and failed (no 404); a ratio store that is not ready puts every id in failed (no 503).dividend differs from /dividend/<stock_id>: it reads stored data only (no refresh), an unknown id or a stock with no dividend history is silently absent (no 404), and an upstream quota problem shows up in failed, not as a 503./studio/market/twstock/sector/overview | Name | Description | Allowed | Default |
|---|---|---|---|
windowint · query | Trading days for relative strength and the window flow sums | 10, 20, 60 | 20 |
body = requests.get(f"{BASE_URL}/studio/market/twstock/sector/overview" , headers=headers, params={"window": 20}, timeout=120).json()# Live capture 2026-11-06 (abridged with ...):# {"date": "2026-11-06",# "summary": {"up": 2, "down": 30, "migrations_today": 3, "foreign_total": -911.9, "foreign_streak": -7,# "trust_total": 266.6, "trust_streak": 19, "margin_change": -423.6, "margin_pctl": 0},# "sectors": [{"slug": "cement", "name": "水泥", "group": "trad", "weight": 0.3,# "returns": {"d1": -1.66, "d5": -4.72, "d10": -1.66, "d20": 4.16, "d60": null, "ytd": null},# "rs": 115.0, "momentum": 112.0, "tail": [[113.1, 97.7], [115.0, 104.2], [115.0, 109.6], [115.0, 112.0]],# "clamped": true, "quadrant": "leading", "migration_days": 4,# "foreign": 4.5, "trust": -0.1, "dealer": 0.3,# "foreign_win": 48.0, "trust_win": 3.7, "dealer_win": 4.3, "foreign_win_prev": 8.4,# "stats": {"rs_up_streak": 2, "foreign_streak": 3, "dealer_streak": 2, "d5_return_pctl_1y": null,# "foreign_buy_days_20d": 15, "foreign_buy_days_pctl_1y": 100}}, ...,# {"slug": "semiconductor", "name": "半導體", "group": "elec", "weight": 55.2,# "returns": {"d1": -4.71, "d5": -12.04, "d10": -14.4, "d20": -20.99, "d60": -11.55, "ytd": 44.86},# "rs": 99.1, "momentum": 100.7, "tail": [[98.0, 100.6], [98.3, 100.5], [98.5, 100.9], [98.9, 100.8]],# "clamped": false, "quadrant": "improving", "migration_days": 6,# "foreign": -662.8, "trust": 135.8, "dealer": 216.8,# "foreign_win": -10057.1, "trust_win": 1402.2, "dealer_win": 865.3, "foreign_win_prev": 1944.2,# "stats": {...}}, ... 32 sectors],# "concentration": {"top3_buy_share": 0.64},# "flow_caps": {"foreign": 320, "trust": 160, "dealer": 30}}leading = [s["name"] for s in body["sectors"] if s["quadrant"] == "leading"]One object (no data wrapper): {"date", "summary", "sectors": [...], "concentration", "flow_caps"}. sectors has the 32 TWSE sector indices in a fixed order.
| Field | Type | Unit | Description |
|---|---|---|---|
date | string | — | Latest trading day of the sector indices |
summary.up / summary.down | int | sectors | Sectors that closed up / down on date |
summary.migrations_today | int | sectors | Sectors that changed quadrant on date |
summary.foreign_total / summary.trust_total | float | TWD 100M (億) | Whole-market 外資 / 投信 net buy on the latest published day (official totals) |
summary.foreign_streak / summary.trust_streak | int | days | Consecutive net-buy (+N) or net-sell (−N) days |
summary.margin_change | float | TWD 100M (億) | Whole-market margin balance change on the latest published day |
summary.margin_pctl | int | 0–100 | Percentile of margin_change against the past year; null with less than a year of history |
sectors[].slug / name / group | string | — | Sector id (used by sector/constituents/<slug>), Chinese name, elec (電子) / fin (金融) / trad (傳產) |
sectors[].weight | float | % | Sector market value ÷ all mapped stocks' market value |
sectors[].returns | object | % | d1, d5, d10, d20, d60, ytd index returns (ytd vs the previous year's last close) |
sectors[].rs | float | index (100 = TAIEX) | Relative strength over window: 100 × (sector close ÷ sector close window days earlier) ÷ (TAIEX close ÷ TAIEX close window days earlier) |
sectors[].momentum | float | index (100 = flat) | 100 + 5-day change in rs |
sectors[].quadrant | string | — | leading (rs ≥ 100, momentum ≥ 100), weakening (rs ≥ 100, momentum < 100), lagging (both < 100), improving (rs < 100, momentum ≥ 100) |
sectors[].migration_days | int | trading days | Consecutive trading days in the current quadrant (looks back up to 90 trading days) |
sectors[].tail | array | — | [rs, momentum] pairs for the 4 days before date, oldest first |
sectors[].clamped | bool | — | true when rs, momentum or a tail point was capped (see Notes) |
sectors[].foreign / trust / dealer | float | TWD 100M (億) | Estimated 外資 / 投信 / 自營商 net buy on date |
sectors[].foreign_win / trust_win / dealer_win | float | TWD 100M (億) | Same, summed over the last window trading days |
sectors[].foreign_win_prev | float | TWD 100M (億) | Foreign sum over the window days before that |
sectors[].stats.rs_up_streak | int | days | Consecutive days rs rose |
sectors[].stats.foreign_streak / dealer_streak | int | days | Consecutive net-buy (+N) / net-sell (−N) days |
sectors[].stats.d5_return_pctl_1y | int | 0–100 | Percentile of the 5-day return against the past year |
sectors[].stats.foreign_buy_days_20d | int | days | Foreign net-buy days out of the last 20 |
sectors[].stats.foreign_buy_days_pctl_1y | int | 0–100 | Percentile of that count against the past year |
concentration.top3_buy_share | float | 0–1 | Share of the day's positive foreign sector flow taken by the top 3 sectors |
flow_caps | object | TWD 100M (億) | {"foreign", "trust", "dealer"}: typical size (P90) of a sector's 20-day flow sum over the past year, for colour scaling; null with less than a year of history |
Any field can be null when its history is too short or the day is not published yet.
| Status | Body | When |
|---|---|---|
| 400 | {"error": "window must be one of [10, 20, 60]"} | Bad window |
| 503 | {"error": "<message>"} | Sector data not available yet |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
summary totals are the official whole-market amounts, so they will not equal the sum of the sectors.rs, momentum and tail are capped for charting (window 10: 88–112, 20: 85–115, 60: 78–122; momentum 88–112) and clamped is set when a cap applied. quadrant and migration_days always use the uncapped values.foreign / trust / dealer are only ever date's own values, so they are null until that day's flows publish. *_win, foreign_win_prev, the streaks and foreign_buy_days_* end on the latest published flow day, which in the afternoon can be the previous trading day.foreign_win / trust_win / dealer_win are null until the window has enough flow days.cement, food, plastic, textile, electric_machinery, wire_cable, chemical, biotech, glass_ceramic, paper, steel, rubber, automobile, semiconductor, computer_peripheral, optoelectronic, communication, electronic_components, electronic_distribution, information_service, other_electronic, construction, shipping, tourism, financial, trading_consumer, oil_gas, green_energy, digital_cloud, sports_leisure, household, other./studio/market/twstock/sector/breadth | Name | Description | Allowed | Default |
|---|---|---|---|
daysint · query | Calendar days back from today | ≥ 1; values above 730 are treated as 730 | 365 |
body = requests.get(f"{BASE_URL}/studio/market/twstock/sector/breadth" , headers=headers, params={"days": 90}, timeout=120).json()# Live capture 2026-11-06 (abridged with ...):# {"dates": ["2026-08-10", "2026-08-11", "2026-08-12", ..., "2026-11-06"],# "pct_up": [76.7, 46.7, 56.7, ..., 6.2]} # 60 trading daysOne object (no data wrapper): {"dates": [...], "pct_up": [...]}, parallel arrays, one element per trading day, oldest first.
| Field | Type | Unit | Description |
|---|---|---|---|
dates | string[] | — | Trading days (YYYY-MM-DD) |
pct_up | float[] | % | Share of the sector indices that closed up that day, out of those with a change figure that day (32 on most days; one decimal) |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "days must be an integer"} | Not an integer |
| 400 | {"error": "days must be positive"} | days < 1 |
| 503 | {"error": "<message>"} | Sector data not available yet |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
/studio/market/twstock/sector/constituents/<slug> | Name | Description | Allowed | Default |
|---|---|---|---|
slugstring · pathRequired | Sector | One of the 32 sector slugs listed under sector/overview |
body = requests.get(f"{BASE_URL}/studio/market/twstock/sector/constituents/semiconductor" , headers=headers, timeout=60).json()# Live capture 2026-11-06 (abridged with ...):# {"date": "2026-11-06", "total": 116,# "stocks": [{"stock_id": "2330", "name": "台積電", "chg": -4.69, "foreign": -487.7,# "themes": [{"slug": "silicon-photonics-cpo",# "name": {"zh": "矽光子/CPO", "en": "Silicon Photonics / CPO", "cn": "硅光子/CPO"}}]},# {"stock_id": "2454", "name": "聯發科", "chg": -2.02, "foreign": -153.8, "themes": []}, ...,# {"stock_id": "2408", "name": "南亞科", "chg": -4.58, "foreign": 19.3,# "themes": [{"slug": "memory", "name": {"zh": "記憶體", "en": "Memory", "cn": "存储器"}}]}, ... 5 rows]}One object (no data wrapper): {"date", "total", "stocks": [...]}. stocks is the sector's 5 largest constituents by market value, largest first.
| Field | Type | Unit | Description |
|---|---|---|---|
date | string | — | Trading day of the prices |
total | int | stocks | Number of constituents in the sector |
stocks[].stock_id / name | string | — | Code, name |
stocks[].chg | float | % | Change on date |
stocks[].foreign | float | TWD 100M (億) | Estimated foreign net buy on date (net shares × close) |
stocks[].themes | array | — | [{"slug", "name"}] concept-stock themes the stock belongs to, name = {"zh", "en", "cn"}; [] when none |
| Status | Body | When |
|---|---|---|
| 404 | {"error": "Unknown sector slug"} | slug is not one of the 32 |
| 503 | {"error": "No recent market price data available"} | No published prices in the last 7 days |
| 503 | {"error": "Upstream rate limit. Please retry shortly."} | Upstream quota exhausted |
chg and foreign are null when that stock's price or flow for the day is missing. On days when market values are not published yet, the 5 stocks fall back to code order./studio/market/twstock/theme/overview | Name | Description | Allowed | Default |
|---|---|---|---|
windowint · query | Trading days for the window flow sums | 10, 20, 60 | 20 |
body = requests.get(f"{BASE_URL}/studio/market/twstock/theme/overview" , headers=headers, params={"window": 20}, timeout=60).json()# Live capture 2026-11-06 (abridged with ...):# {"date": "2026-11-06", "list_ym": "2026-10", "first_ym": "2026-10", "list_age_days": 24, "stale_months": 1,# "pctl_includes_backfill": true,# "summary": {"up": 0, "down": 6, "top": {"slug": "ai", "d20": -20.32},# "bottom": {"slug": "pcb-abf-substrate", "d20": -38.51},# "foreign_top": {"slug": "ai", "foreign_win": -70.1, "foreign_win_ex_top": 40.4, "top_name": "鴻海"}},# "themes": [{"slug": "ai", "name": {"zh": "AI", "en": "AI", "cn": "AI"}, "count": 12, "snapshot_ym": "2026-10",# "indexable": true,# "returns": {"d1": -4.84, "d5": -13.88, "d10": -17.83, "d20": -20.32, "d60": -13.27, "ytd": 24.78},# "returns_backfill": {"d1": false, "d5": false, "d10": false, "d20": true, "d60": true, "ytd": true},# "foreign": -43.3, "trust": 20.0, "dealer": 22.7,# "foreign_win": -70.1, "trust_win": -76.2, "dealer_win": 123.3, "foreign_win_prev": -716.1,# "foreign_win_ex_top": 40.4, "foreign_buy_members": 4,# "top": {"stock_id": "2317", "name": "鴻海", "mv_share": 40.0},# "top5": [{"stock_id": "2317", "name": "鴻海"}, {"stock_id": "2382", "name": "廣達"}, ...],# "stats": {"foreign_streak": -4, "dealer_streak": 6, "d5_return_pctl_1y": 0,# "foreign_buy_days_20d": 8, "foreign_buy_days_pctl_1y": 52}}, ... 6 themes],# "flow_caps": {"foreign": 1480, "trust": 430, "dealer": 180}}One object (no data wrapper): {"date", "list_ym", "first_ym", "list_age_days", "stale_months", "pctl_includes_backfill", "summary", "themes": [...], "flow_caps"}.
| Field | Type | Unit | Description |
|---|---|---|---|
date | string | — | Latest trading day of the theme indices |
list_ym | string | — | Month of the newest theme lists, YYYY-MM |
first_ym | string | — | Month of the first list of any theme |
list_age_days / stale_months | int | days / months | Age of the newest lists: days since they took effect, months since their list month |
pctl_includes_backfill | bool | — | true when a percentile's one-year history reaches back before a list took effect |
summary.up / summary.down | int | themes | Themes up / down on date |
summary.top / summary.bottom | object | % | {"slug", "d20"}: best and worst 20-day return |
summary.foreign_top | object | TWD 100M (億) | {"slug", "foreign_win", "foreign_win_ex_top", "top_name"}: theme with the largest foreign net buy once its largest stock is taken out |
themes[].slug | string | — | Theme id (used by the other theme endpoints) |
themes[].name | object | — | {"zh", "en", "cn"} |
themes[].count | int | stocks | Members in the current list (delisted stocks excluded) |
themes[].snapshot_ym | string | — | Month of the theme's current list |
themes[].indexable | bool | — | true when the theme has at least 5 members and its list is at most 90 days old |
themes[].returns | object | % | d1, d5, d10, d20, d60, ytd returns of the theme index |
themes[].returns_backfill | object | — | Same keys, true when that return starts before the theme's first list took effect |
themes[].foreign / trust / dealer | float | TWD 100M (億) | Estimated net buy of the members on date; null until that day's flows publish |
themes[].foreign_win / trust_win / dealer_win | float | TWD 100M (億) | Same, summed over the last window trading days |
themes[].foreign_win_prev | float | TWD 100M (億) | Foreign sum over the window days before that |
themes[].foreign_win_ex_top | float | TWD 100M (億) | foreign_win without the largest member's own foreign flow |
themes[].foreign_buy_members | int | stocks | Members with a positive foreign sum over the window |
themes[].top | object | % | {"stock_id", "name", "mv_share"}: largest member and its share of the theme's market value, measured on the list's effective date |
themes[].top5 | array | — | [{"stock_id", "name"}]: 5 largest members by market value on the list's effective date |
themes[].stats | object | — | foreign_streak, dealer_streak (±days), d5_return_pctl_1y, foreign_buy_days_20d, foreign_buy_days_pctl_1y — same meaning as in sector/overview |
flow_caps | object | TWD 100M (億) | {"foreign", "trust", "dealer"}: typical size (P90) of a theme's 20-day flow sum, for colour scaling; null with less than a year of flow history |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "window must be one of [10, 20, 60]"} | Bad window |
| 503 | {"error": "not_yet_effective"} | No theme list is in effect yet |
theme/constituents/<slug>). Current slugs: ai, silicon-photonics-cpo, memory, pcb-abf-substrate, thermal-cooling, robotics.returns_backfill marks them.*_win, the streaks and foreign_buy_days_* end on the latest published flow day, which in the afternoon can be the previous trading day.themes./studio/market/twstock/theme/constituents/<slug> | Name | Description | Allowed | Default |
|---|---|---|---|
slugstring · pathRequired | Theme | A theme slug from theme/overview |
body = requests.get(f"{BASE_URL}/studio/market/twstock/theme/constituents/memory" , headers=headers, timeout=60).json()# Live capture 2026-11-06 (abridged with ...):# {"date": "2026-11-06", "slug": "memory", "status": "active", "snapshot_ym": "2026-10",# "published_at": "2026-10-14", "effective_date": "2026-10-15", "first_ym": "2026-10",# "list_age_days": 24, "stale_months": 1, "count": 9, "indexable": true, "gated": false,# "name": {"zh": "記憶體", "en": "Memory", "cn": "存储器"},# "intro": {"zh": "記憶體概念股是做 DRAM 與 Flash 等記憶體的公司,…", "en": "Memory stocks make DRAM, flash and other memory, …", "cn": "…"},# "changes": {"added": [], "removed": [], "prev_ym": null}, "related": [],# "stocks": [{"stock_id": "2408", "name": "南亞科", "market": "twse", "sector_slug": "semiconductor",# "chg": -4.58, "foreign": 19.32, "ret20": -34.57, "rev_yoy": 487.73, "roe": 61.61,# "foreign_share_chg_20d": -2.39, "disposal": false, "delisted": false, "last_trade_date": null,# "also": [],# "reason": {"zh": "DRAM 製造,產品含 DDR5、LPDDR5/5X 與 DDR4",# "en": "Manufactures DRAM, including DDR5, LPDDR5/5X and DDR4", "cn": "…"},# "sources": [{"kind": "filing", "date": "2026-10-12",# "label": {"en": "Nanya Technology investor conference slides, 2026-10-12", ...},# "url": "https://mopsov.twse.com.tw/nas/STR/240820261012M001.pdf"}, ...]}, ... 9 rows]}One object (no data wrapper).
| Field | Type | Description |
|---|---|---|
date | string | Trading day of the per-stock figures |
slug, status | string | Theme id, active |
name / intro | object | {"zh", "en", "cn"} theme name / one-paragraph description |
snapshot_ym | string | Month of the current list |
published_at / effective_date | string | Day the list was published / took effect |
first_ym | string | Month of the theme's first list |
list_age_days / stale_months | int | Days since the list took effect / months since its list month |
count | int | Members, delisted stocks excluded |
indexable | bool | true with at least 5 members and a list at most 90 days old |
changes | object | {"added", "removed", "prev_ym"}: stock ids added / removed against the previous list (prev_ym null for the first list) |
related | array | [{"slug", "overlap"}]: up to 3 other themes sharing members, most shared first |
gated | bool | Always false for API keys |
stocks[].stock_id / name | string | Code, name |
stocks[].market | string | twse or tpex |
stocks[].sector_slug | string | Sector slug as in sector/overview by industry category (OTC stocks included); null when unmapped |
stocks[].chg | float | Change % on date |
stocks[].foreign | float | Estimated foreign net buy on date, TWD 100M (億); null until that day's flows publish |
stocks[].ret20 | float | Dividend-adjusted 20-trading-day return, % |
stocks[].rev_yoy | float | Latest monthly revenue vs a year earlier, % |
stocks[].roe | float | Trailing four-quarter ROE, % |
stocks[].foreign_share_chg_20d | float | Change in foreign shareholding over 20 trading days, percentage points |
stocks[].disposal | bool | Under disposition today |
stocks[].delisted / last_trade_date | bool / string | Delisted since the list was made, and its last trading day (null otherwise) |
stocks[].also | string[] | Other themes holding the stock |
stocks[].reason | object | {"zh", "en", "cn"} why the stock is in the theme |
stocks[].sources | array | [{"kind", "label", "url", "date"}]: public sources for the reason; kind filing or news, label {"zh", "en", "cn"} |
| Status | Body | When |
|---|---|---|
| 404 | {"error": "Unknown theme"} | No such slug |
| 410 | {"error": "Theme retired", "retired": true} | Theme retired |
| 503 | {"error": "not_yet_effective"} | The theme's list is not in effect yet |
stocks (listed last) with delisted: true; count leaves them out.rev_yoy, roe and foreign_share_chg_20d can each be null on their own when that figure is missing for a stock./studio/market/twstock/theme/<slug>/index | Name | Description | Allowed | Default |
|---|---|---|---|
slugstring · pathRequired | Theme | A theme slug from theme/overview | |
rangestring · query | Calendar window ending on the latest day (92 / 366 / 1,096 days) | 3m, 1y, 3y | 3m |
body = requests.get(f"{BASE_URL}/studio/market/twstock/theme/memory/index" , headers=headers, params={"range": "3y"}, timeout=60).json()# Live capture 2026-11-06 (abridged with ...):# {"slug": "memory", "range": "3y", "base_date": "2026-10-14", "first_ym": "2026-10",# "points": [{"date": "2023-11-06", "value": 19.82, "taiex": 31.86, "tpex": 48.39, "is_backfill": true,# "n": 9, "snapshot_ym": "2026-10"}, ...,# {"date": "2026-10-14", "value": 100.0, "taiex": 100.0, "tpex": 100.0, "is_backfill": true, "n": 9,# "snapshot_ym": "2026-10"}, ...,# {"date": "2026-11-06", "value": 79.89, "taiex": 81.65, "tpex": 72.37, "is_backfill": false,# "n": 9, "snapshot_ym": "2026-10"}]} # 728 pointsOne object (no data wrapper): {"slug", "range", "base_date", "first_ym", "points": [...]}, points oldest first.
| Field | Type | Description |
|---|---|---|
base_date | string | Day the index is 100 (the trading day before the theme's first list took effect) |
first_ym | string | Month of the theme's first list |
points[].date | string | Trading day |
points[].value | float | Theme index, 100 on base_date |
points[].taiex / tpex | float | TAIEX / TPEx total-return indices rescaled to 100 on base_date, for comparison |
points[].is_backfill | bool | true before the theme's first list took effect (members taken from that first list) |
points[].n | int | Members in the index that day |
points[].snapshot_ym | string | Month of the list the members came from |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "range must be one of ['3m', '1y', '3y']"} | Bad range |
| 404 | {"error": "Unknown theme"} | No such slug |
| 410 | {"error": "Theme retired", "retired": true} | Theme retired |
| 503 | {"error": "not_yet_effective"} | The theme's list is not in effect yet |
value by taiex (or tpex) at each point./studio/market/twstock/chip_breadth/<scope> | Name | Description | Allowed | Default |
|---|---|---|---|
scopestring · pathRequired | Group type | theme, sector | |
windowint · query | Trading days the net buy is summed over | 10, 20, 60 | 20 |
inststring · query | Investor the groups are ranked by | foreign, trust | foreign |
body = requests.get(f"{BASE_URL}/studio/market/twstock/chip_breadth/sector" , headers=headers, params={"window": 20, "inst": "foreign"}, timeout=60).json()# Live capture 2026-11-06 (abridged with ...):# {"scope": "sector", "window": 20, "inst": "foreign", "as_of": "2026-11-06", "min_group": 6,# "baseline": {"universe": "twse",# "foreign": {"buy": 648, "total": 1091, "ratio": 59.395050412465636},# "trust": {"buy": 271, "total": 1091, "ratio": 24.839596700274978}},# "groups": [{"slug": "trading_consumer", "name": "貿易百貨", "total": 21,# "foreign": {"buy": 20, "ratio": 95.23809523809523, "gap": 36, "rank": 1},# "trust": {"buy": 4, "ratio": 19.047619047619047, "gap": -6, "rank": 16}},# {"slug": "shipping", "name": "航運", "total": 28,# "foreign": {"buy": 24, "ratio": 85.71428571428571, "gap": 26, "rank": 2},# "trust": {"buy": 7, "ratio": 25.0, "gap": 0, "rank": 12}}, ... 31 groups],# "excluded": [{"slug": "glass_ceramic", "name": "玻璃陶瓷", "total": 5}],# "sources": {"institutional": {"zh": "臺灣證券交易所", "en": "TWSE", "cn": "台湾证券交易所"}}}One object (no data wrapper): {"scope", "window", "inst", "as_of", "min_group", "baseline", "groups": [...], "excluded": [...], "sources"}.
| Field | Type | Description |
|---|---|---|
as_of | string | Last day of the flow window |
min_group | int | Groups with fewer counted stocks than this are not ranked (6) |
baseline.universe | string | Market the groups are compared with: twse for sectors, twse+tpex for themes |
baseline.foreign / baseline.trust | object | {"buy", "total", "ratio"}: common stocks in that market net bought over the window, all counted, and the share in % |
groups[].slug / name | — | Group id; name is a string for sectors and {"zh", "en", "cn"} for themes |
groups[].total | int | Counted stocks in the group |
groups[].foreign / groups[].trust | object | {"buy", "ratio", "gap", "rank"}: stocks net bought, their share in %, the share minus the baseline share in percentage points (integer), and the rank by share |
excluded | array | [{"slug", "name", "total"}]: groups under min_group |
sources.institutional | object | {"zh", "en", "cn"} name of the exchange(s) behind the flows |
groups is ordered by inst's rank; both investors' ranks are always present.
| Status | Body | When |
|---|---|---|
| 400 | {"error": "window must be one of [10, 20, 60]"} | Bad window |
| 400 | {"error": "inst must be one of ['foreign', 'trust']"} | Bad inst |
| 404 | {"error": "Unknown scope"} | scope is not theme / sector |
| 503 | {"error": "not_yet_effective"} | theme: no theme list in effect yet |
| 503 | {"error": "Data temporarily unavailable. Please retry shortly."} | Upstream quota exhausted or the stock-to-sector map is unavailable |
sector/overview (上市 only); themes are the lists of theme/overview (上市 + 上櫃) — which is why their baselines differ.gap rounds half away from zero on the exact fraction./studio/market/twstock/chip_breadth/<scope>/<slug> | Name | Description | Allowed | Default |
|---|---|---|---|
scopestring · pathRequired | Group type | theme, sector | |
slugstring · pathRequired | Group | A sector slug (sector/overview) or theme slug (theme/overview) | |
windowint · query | Trading days the net buy is summed over | 10, 20, 60 | 20 |
body = requests.get(f"{BASE_URL}/studio/market/twstock/chip_breadth/theme/memory" , headers=headers, params={"window": 20}, timeout=60).json()# Live capture 2026-11-06 (abridged with ...):# {"scope": "theme", "window": 20, "as_of": "2026-11-06", "price_as_of": "2026-11-06", "min_group": 6,# "baseline": {"universe": "twse+tpex",# "foreign": {"buy": 1106, "total": 1983, "ratio": 55.77407967725668},# "trust": {"buy": 333, "total": 1983, "ratio": 16.792738275340394}},# "slug": "memory", "ranked": true,# "group": {"slug": "memory", "name": {"zh": "記憶體", "en": "Memory", "cn": "存储器"}, "total": 9,# "foreign": {"buy": 1, "ratio": 11.11111111111111, "gap": -45, "rank": 5},# "trust": {"buy": 5, "ratio": 55.55555555555556, "gap": 39, "rank": 4}},# "stocks": [{"stock_id": "2408", "name": "南亞科", "market": "twse", "foreign": "sell", "trust": "sell",# "foreign_20d": -380.2, "market_cap": 11851.46, "ret_20d": -34.57, "themes": [],# "disposal": false, "notice": false},# {"stock_id": "2344", "name": "華邦電", "market": "twse", "foreign": "sell", "trust": "sell",# "foreign_20d": -35.0, "market_cap": 5688.19, "ret_20d": -32.11, "themes": [],# "disposal": false, "notice": false}, ... 9 rows],# "excluded_count": 0, "alerts_available": true,# "sources": {"institutional": {"zh": "臺灣證券交易所、證券櫃檯買賣中心", "en": "TWSE, TPEx", ...},# "alerts": {"zh": "金融監督管理委員會證券期貨局", "en": "Securities and Futures Bureau, FSC", ...}}}One object (no data wrapper): the ranking's scope, window, as_of, min_group and baseline, plus:
| Field | Type | Description |
|---|---|---|
price_as_of | string | Day the prices and returns end on |
slug | string | Group |
group | object | The group's row as in the ranking (rank missing when it is not ranked) |
ranked | bool | false when the group is under min_group |
stocks[].stock_id / name / market | string | Code, name, twse / tpex |
stocks[].foreign / trust | string | buy, sell or flat over the window |
stocks[].foreign_<N>d | float | Estimated foreign net buy over the window, TWD 100M (億); <N> = window |
stocks[].market_cap | float | TWD 100M (億) |
stocks[].ret_<N>d | float | Return over the window, % (dividend-adjusted where available) |
stocks[].themes | array | [{"slug", "name"}] every theme holding the stock (for scope theme, the requested theme is left out), name = {"zh", "en", "cn"} |
stocks[].disposal / notice | bool | Under disposition / attention notice on as_of; null when that data is unavailable |
excluded_count | int | Members not counted (non-common or no flow figure) |
alerts_available | bool | false when the disposition / attention data could not be read |
sources | object | {"institutional", "alerts"}, each {"zh", "en", "cn"} |
stocks holds the counted members only (its length is group.total), largest market cap first.
| Status | Body | When |
|---|---|---|
| 400 | {"error": "window must be one of [10, 20, 60]"} | Bad window |
| 404 | {"error": "Unknown scope"} | scope is not theme / sector |
| 404 | {"error": "Unknown group"} | No such slug in that scope |
| 410 | {"error": "Theme retired", "retired": true} | Theme retired |
| 503 | {"error": "not_yet_effective"} | The theme's list is not in effect yet |
| 503 | {"error": "Data temporarily unavailable. Please retry shortly."} | Upstream quota exhausted or the stock-to-sector map is unavailable |
disposal / notice are judged on as_of: a disposition period covering that day, an attention notice announced on it./studio/market/twstock/screener/run JSON request body (send with json=; any other body is a 400). Every field is optional; {} returns the 300 largest common stocks by market cap.
| Name | Description | Allowed | Default |
|---|---|---|---|
filtersarray · body | Conditions, shapes below | ≤ 40 conditions, all must match (AND) | [] |
include_typesstring[] · body | Add these security types to the default universe of common stocks | Subset of etf, etn, reit, preferred, dr | [] |
sortobject · body | Order of rows; null values sort last | indicator = any numeric key below; dir = asc / desc | {"indicator": "market_cap", "dir": "desc"} |
limitint · body | Rows returned (total still counts every match) | 1–300 | 300 |
Condition shapes in filters:
| Condition | Shape | Matches |
|---|---|---|
| Numeric | {"indicator": "per", "operator_id": 4, "value": 15} | operator_id 1 >, 2 <, 3 ≥, 4 ≤; a null value never matches |
| Market | {"indicator": "market", "op": "in", "values": ["twse"]} | op = in / not_in; values twse (上市), tpex (上櫃) |
| Industry | {"indicator": "industry", "op": "in", "values": ["24", "28"]} | Exchange industry codes (Notes) |
| Theme | {"indicator": "theme", "op": "not_in", "values": ["ai"]} | Concept-stock theme slugs (Notes) |
| Exclude | {"indicator": "exclude", "values": ["disposal", "notice"]} | Drops 處置股 in force today / 注意股 announced since the snapshot day |
Set conditions take 1–50 values. An unknown indicator, operator or value is a 400 — nothing is skipped silently.
Numeric indicators (also the numeric columns of every row):
| Key | Unit | Description |
|---|---|---|
per | × | P/E: close ÷ trailing four-quarter EPS, as published by the exchange; null for loss-makers |
pbr | × | P/B: close ÷ latest book value per share, as published by the exchange; null when the exchange publishes none (P/B ≤ 0) |
dividend_yield | % | Trailing-year cash dividends ÷ close, as published by the exchange; null above 50% (not comparable) |
roe_ttm | % | Trailing four-quarter net income ÷ average equity |
gross_margin_q / operating_margin_q | % | Latest quarter; not reported by financials |
eps_ttm | TWD | Sum of the last four quarters |
rev_yoy | % | Latest reported month's revenue vs the same month a year earlier |
market_cap | TWD 100M (億) | Close × shares outstanding |
turnover_20d | TWD 100M (億) | Average daily traded value over the last 20 trading days |
close | TWD | Latest close |
ret_5d / ret_20d / ret_60d | % | Dividend-adjusted return over 5 / 20 / 60 trading days |
foreign_5d / foreign_20d / foreign_60d | TWD 100M (億) | Estimated foreign net buy over 5 / 20 / 60 trading days (daily net shares × that day's close); positive = net buy |
trust_5d / trust_20d / trust_60d | TWD 100M (億) | Same for investment trusts (投信) |
cond = { "filters": [ {"indicator": "dividend_yield", "operator_id": 3, "value": 5}, {"indicator": "per", "operator_id": 4, "value": 15}, {"indicator": "market_cap", "operator_id": 3, "value": 300}, {"indicator": "exclude", "values": ["disposal", "notice"]}, ], "sort": {"indicator": "dividend_yield", "dir": "desc"}, "limit": 50,}body = requests.post(f"{BASE_URL}/studio/market/twstock/screener/run" , headers=headers, json=cond, timeout=60).json()# Live capture 2026-11-06 (abridged with ...):# {"as_of": "2026-11-06",# "dates": {"price": "2026-11-06", "per": "2026-11-06", "market_cap": "2026-11-06", "flows": "2026-11-06"},# "total": 42,# "columns": [{"key": "close", "name": {"zh": "收盤", "en": "Close"}, "value_format": "twd",# "value_decimals": 2, "signed": false, "colored": false, "family": null, "window": null,# "filtered": false},# {"key": "per", "name": {"zh": "本益比", "en": "P/E"}, "value_format": "x", "value_decimals": 1,# "signed": false, "colored": false, "family": null, "window": null, "filtered": true}, ... 7 columns],# "sort": {"indicator": "dividend_yield", "dir": "desc"},# "rows": [{"stock_id": "2542", "name": "興富發", "market": "twse", "sec_type": "common", "industry": "14",# "fin_quarter": "2026Q2", "rev_month": "2026-09", "adj": true, "themes": [],# "disposal": false, "notice": false,# "close": 37.75, "per": 8.74, "pbr": 1.61, "dividend_yield": 10.6, "roe_ttm": 20.583,# "gross_margin_q": 31.8475, "operating_margin_q": 25.3319, "eps_ttm": 4.32, "rev_yoy": 103.7265,# "market_cap": 812.789, "turnover_20d": 3.4225,# "ret_5d": -3.9452, "ret_20d": -1.1936, "ret_60d": -6.5688,# "foreign_5d": 3.2337, "foreign_20d": 25.2619, "foreign_60d": 24.2922,# "trust_5d": 0.3288, "trust_20d": -2.7693, "trust_60d": 16.1917}, ... 42 rows]}ids = [r["stock_id"] for r in body["rows"]]One object (no data wrapper).
| Field | Type | Description |
|---|---|---|
as_of | string | Snapshot trading day |
dates | object | As-of day per source: price, per, market_cap, flows (flows can be one day before as_of) |
total | int | Matches before limit |
columns | array | The result table's columns: the defaults (close, per, pbr, dividend_yield, roe_ttm, rev_yoy, market_cap) plus every filtered or sorted indicator. Each has key, name ({"zh", "en"}), value_format (x / pct / twd / twd_100m), value_decimals, signed, colored, family, window, filtered |
sort | object | The sort applied |
rows[].stock_id / name | string | Code, name |
rows[].market | string | twse or tpex (lowercase here) |
rows[].sec_type | string | common, etf, etn, reit, preferred, dr |
rows[].industry | string | Exchange industry code; null when the exchange gives none |
rows[].fin_quarter | string | Quarter behind the ratio columns, e.g. 2026Q2 (differs by stock during filing season) |
rows[].rev_month | string | Month behind rev_yoy, e.g. 2026-09 |
rows[].adj | bool | false when the returns could not be dividend-adjusted |
rows[].themes | string[] | Theme slugs the stock belongs to |
rows[].disposal / notice | bool | Under disposition today / attention notice since as_of; null when that data is unavailable |
rows[].<numeric key> | float | Every numeric indicator above, rounded to 4 decimals; null when missing |
| Status | Body | When |
|---|---|---|
| 400 | {"error": "<what is wrong>"} | Invalid body, e.g. "body must be a JSON object", "limit must be an integer 1–300", "unknown indicator 'pe'" |
| 503 | {"error": "Data temporarily unavailable. Please retry shortly."} | Snapshot not available |
| 503 | {"error": "themes_unavailable", "message": "..."} | A theme condition while theme lists are not in effect — drop it or retry later |
| 503 | {"error": "alerts_unavailable", "message": "..."} | An exclude condition while attention / disposition data is unavailable — drop it or retry shortly |
include_types.dates before comparing with other endpoints.market is lowercase here (twse / tpex), unlike market_value/all (TWSE / TPEx).01 水泥工業, 02 食品工業, 03 塑膠工業, 04 紡織纖維, 05 電機機械, 06 電器電纜, 08 玻璃陶瓷, 09 造紙工業, 10 鋼鐵工業, 11 橡膠工業, 12 汽車工業, 14 建材營造, 15 航運業, 16 觀光餐旅, 17 金融保險, 18 貿易百貨, 19 綜合, 20 其他, 21 化學工業, 22 生技醫療, 23 油電燃氣, 24 半導體, 25 電腦及週邊設備, 26 光電, 27 通信網路, 28 電子零組件, 29 電子通路, 30 資訊服務, 31 其他電子, 32 文化創意, 33 農業科技, 34 電子商務, 35 綠能環保, 36 數位雲端, 37 運動休閒, 38 居家生活, 91 存託憑證.ai, silicon-photonics-cpo (矽光子/CPO), memory (記憶體), pcb-abf-substrate (PCB/ABF 載板), thermal-cooling (散熱), robotics (機器人).per is null for loss-making companies, so per < 10 does not pick them up; a null never matches any numeric condition.