Python client for the 金晰數據 / clarifindata Taiwan-stock data API
Project description
clarifindata — Python client
Python client for the 金晰數據 / clarifindata Taiwan-stock data API (89 datasets: prices, chips, fundamentals, derivatives, macro — full history, refreshed daily).
pip install clarifindata # core
pip install 'clarifindata[pandas]' # + DataFrame output (as_df=True)
pip install 'clarifindata[all]' # + pandas + HTTP/2
Quickstart
from clarifindata import Client, datasets
cfd = Client(api_key="cfd_demo_free_0001") # free demo key
# typed dataset names (autocomplete + typo-safe), DataFrame output
df = cfd.get(datasets.TaiwanStockPrice, stock_id="2330",
start="2026-04-01", end="2026-06-03", as_df=True)
print(df.head())
Demo keys (rate-limited, for trying out): cfd_demo_free_0001 (Free),
cfd_demo_lite_0001 (Lite). Get your own at https://clarifindata.com/signup.
Features
| What | How |
|---|---|
Auto-retry 429/5xx/timeouts (honours Retry-After, exp backoff) |
on by default; tune max_retries, backoff_base |
| Rate-limit aware | cfd.rate_limit_remaining; warns at 80% used |
| DataFrame output | cfd.get(..., as_df=True) |
| Full-history streaming (auto-paginates the 10 000-row cap) | cfd.iter_history(ds, stock_id=..., since="2015-01-01") |
| Async / concurrency | AsyncClient (same surface) |
| Multi-dataset pull | cfd.bulk_pull([...], start=, end=) |
| Disk cache (for slow-changing datasets) | Client(cache_dir="./.cache", cache_ttl=86400) |
| Typed errors w/ suggestions | ClarifindataError(dataset, status, detail, suggestion) |
| Logging | logging.getLogger("clarifindata") (DEBUG = request/response) |
Full history (any range, no manual chunking)
for batch in cfd.iter_history(datasets.TaiwanStockPrice, stock_id="2330", since="2015-01-01"):
process(batch) # one year per batch, streamed
df = cfd.history(datasets.TaiwanStockPrice, stock_id="2330", since="2015-01-01", as_df=True)
Concurrency (fetch many stocks)
import asyncio
from clarifindata import AsyncClient, datasets
async def main():
async with AsyncClient(api_key="...") as cfd:
tasks = [cfd.get(datasets.TaiwanStockPrice, stock_id=s, as_df=True)
for s in ("2330", "2317", "2454")]
return await asyncio.gather(*tasks)
frames = asyncio.run(main())
Natural-language queries (Plus tier)
ans = cfd.ask("找出 2330 在 2026 年 4 月最高收盤價那天", as_df=True)
Errors
from clarifindata import TierError, RateLimitError, ValidationError
try:
cfd.get("TaiwanStockPirce") # typo
except ValidationError as e:
print(e) # Unknown dataset 'TaiwanStockPirce'. Did you mean 'TaiwanStockPrice'? ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clarifindata-0.2.5.tar.gz.
File metadata
- Download URL: clarifindata-0.2.5.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
597d8e87721b7224e8aeae4479c43656a7562b60c3f3bedb3762173f0de020ee
|
|
| MD5 |
a38e59d00af63c44fc3d624a3548647b
|
|
| BLAKE2b-256 |
84afe7c173c797c9d3d9fb9c6bc069aa381b265acbf86c968a6e6e02681ff46b
|
File details
Details for the file clarifindata-0.2.5-py3-none-any.whl.
File metadata
- Download URL: clarifindata-0.2.5-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4c242ef126d72a936ed75b07dd030d3fa5f6db1e02e021684d6767b9fcc51b6
|
|
| MD5 |
1de1c442b08ad970698ecb42ba0f5dbf
|
|
| BLAKE2b-256 |
51679ec561a003902224b0331f95e6fa6d5029ec53b3606116c696d573efc9fe
|