How to get TWSE data programmatically (Python / API)
You can get TWSE data programmatically in three ways: call the official TWSE OpenAPI and parse the JSON yourself, use a data provider's REST API, or let an AI agent fetch it over an MCP server. With TW Market Data you sign up for a free API key and make a single HTTP request with an X-API-Key header, and the response is clean JSON.
Python quick start
Request the TWSE daily price dataset and read the JSON rows:
import requests
headers = {"X-API-Key": "your_api_key_here"}
url = "https://api.twmarketdata.com/v2/datasets/twse-daily-price?symbol=2330&limit=10"
print(requests.get(url, headers=headers).json())Read coverage and data gaps before you rely on a series
Check the freshness and data_gaps signals in the response and on the dataset page rather than assuming full history. TW Market Data is TWSE-first; TPEx historical depth is disclosed per dataset.
Free tier for testing
The free plan includes the basic datasets with a monthly request quota so you can validate your integration end-to-end before upgrading. A Python SDK (pip install) is planned but not yet published.
常見問題
1How do I authenticate?
2What does a request look like?
3Can I try it without an API key?
4How do I get TWSE data from the official API in Python instead?
5How do I avoid look-ahead bias?
想自己查這些資料?免費註冊。