Building an AI agent? Start with /llms.txt for the full site index.
Docs
Call the TW Market Data public API from Python, with requestId and credits metadata on every result.
The Python SDK is a local/dev preview. Install it from a checkout of the repository in editable mode to try it locally.
# from a checkout of the SDK repositorypip install -e packages/python-sdkfrom twmarketdata import TWMarketDataClient
client = TWMarketDataClient(
api_key="sk_live_xxx",
base_url="https://twmarketdata.com",
timeout=10,
)twse_daily_price and issuer_profile are the two most useful places to start.
price = client.twse_daily_price(symbol="2330", limit=1)
profile = client.issuer_profile(symbol="2330")
print(price.data)
print(profile.data)result = client.monthly_revenue(symbol="2330", limit=12)
print(result.meta.request_id)
print(result.meta.dry_run)
print(result.meta.credits_cost)
print(result.meta.credits_charged)
print(result.meta.plan)from twmarketdata import (
AuthenticationError,
EntitlementError,
InsufficientCreditsError,
NotFoundError,
UpstreamError,
)
try:
data = client.twse_daily_price(symbol="2330", limit=1)
except AuthenticationError:
print("API key is not valid")
except EntitlementError:
print("this dataset is not enabled on your current plan")
except InsufficientCreditsError:
print("not enough credits")
except NotFoundError:
print("dataset does not exist")
except UpstreamError:
print("upstream service error")Manage the key and the base URL through environment variables, locally and in CI.
export TWMD_API_KEY=sk_live_xxxexport TWMD_BASE_URL=https://twmarketdata.com