Taiwan Stock Exchange (TWSE) API for Openclaw

A developer integration that enables programmatic retrieval and analysis of Taiwan Stock Exchange open data without authentication.

nanookai
v1.0.0
Jul 8, 2026
1
353
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install twse-api

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install twse-api using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Taiwan Stock Exchange (TWSE) API?

The TWSE OpenAPI skill connects software applications directly to the official open data repository of the Taiwan Stock Exchange. It provides developer-ready access to daily stock prices, dividend yields, P/E ratios, market indices, and detailed corporate financials. By implementing this tool within Openclaw Skills, developers can fetch and evaluate financial snapshots from the Taiwan market without managing API keys or subscription fees.

The integration serves as a secure gateway for collecting full-market datasets. Because the official API delivers complete JSON arrays rather than server-side filtered queries, this skill is structured to process full payloads client-side, enabling efficient filtering and custom calculations for specified stock codes.

Taiwan Stock Exchange (TWSE) API Use Cases

  • Retrieving daily stock quotes, volume data, and closing values for Taiwan listed companies.
  • Extracting valuation metrics such as dividend yields, P/E ratios, and P/B ratios across active securities.
  • Querying company profiles, monthly revenue figures, and general industry financial statements.
  • Accessing trading schedules, ex-dividend calendars, and market holidays to coordinate automated trade monitoring.
  • Processing whole-market indexes and history, including the TAIEX.

How Taiwan Stock Exchange (TWSE) API Works

  1. Identify the appropriate endpoint for the desired financial metric from the catalog categories.
  2. Initiate a standard HTTP GET request to the target TWSE OpenAPI path.
  3. Retrieve the raw JSON dataset, which contains full-market snapshots in flat array formats.
  4. Apply client-side parsing scripts to isolate data for designated stock codes.
  5. Standardize properties by converting Traditional Chinese JSON keys to English naming conventions.
  6. Format dates from ROC (Minguo) notation to standard Gregorian representations and clean numeric strings.

Taiwan Stock Exchange (TWSE) API Setup

This integration relies on the public, open-data API provided by the Taiwan Stock Exchange, which requires no registration. To query the endpoints using tools managed under Openclaw Skills, you can interact with the endpoints directly.

To fetch daily OHLC data and extract data for a specific stock code (e.g., TSMC - 2330) using curl and Python, run the following commands:

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'])"

For a direct programmatic implementation in Python, use the following snippet:

import json, urllib.request

BASE_URL = 'https://openapi.twse.com.tw/v1'

def fetch_twse_data(endpoint):
    with urllib.request.urlopen(f'{BASE_URL}{endpoint}') as response:
        return json.load(response)

# Fetch daily stock valuations
market_data = fetch_twse_data('/exchangeReport/BWIBBU_ALL')
target_stock = next(item for item in market_data if item['Code'] == '2330')
print(target_stock)

Taiwan Stock Exchange (TWSE) API Data Schema & Taxonomy

Endpoint Categories and Schema Mapping

Endpoints are grouped into distinct categories. Field names vary between English keys and Traditional Chinese keys depending on the source dataset.

Dataset Group Reference Endpoint Core Features Key Format
Securities Trading /exchangeReport/STOCK_DAY_ALL Daily quotes, valuations, margins English (e.g., Code, ClosingPrice)
Corporate Governance /opendata/t187ap03_L Profiles, ESG disclosures, insider data Traditional Chinese (e.g., 公司代號, 公司名稱)
Financial Statements /opendata/t187ap05_L Monthly revenue, balance sheets Traditional Chinese (e.g., 營業收入-當月營收)
Indices /indicesReport/MI_5MINS_HIST Daily TAIEX history English (e.g., Date, OpeningIndex)

Data Normalization Guidelines

  • Date Adjustments: Most datasets use the ROC calendar (e.g., 1150706 representing July 6, 2026). Convert this format by adding 1911 to the leading three digits to get the Gregorian year.
  • Numeric Formatting: Numeric attributes are returned as string fields and may contain commas (e.g., "1,005,300") or dashes (e.g., "-") for blank fields. These must be sanitized before conversion to numeric data types.

Taiwan Stock Exchange (TWSE) API Advanced Features

  • Local data caching strategies to store daily snapshots, reducing latency and network traffic during multi-agent analysis.
  • Dynamic schema translators that map varying language keys into a uniform database layout.
  • Flexible error correction for data handling, managing formatted numeric strings and ROC date conversions automatically.
  • Scheduling pipelines within Openclaw Skills to pull and store market data after closing hours.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*