Skip to main content

Python client for the 金晰數據 / clarifindata Taiwan-stock data API

Project description

clarifindata — Python client

Python client for the 金晰數據 / clarifindata Taiwan-stock data API (82 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clarifindata-0.2.7.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clarifindata-0.2.7-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file clarifindata-0.2.7.tar.gz.

File metadata

  • Download URL: clarifindata-0.2.7.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

Hashes for clarifindata-0.2.7.tar.gz
Algorithm Hash digest
SHA256 ddaadce3ab1204f2a1533b6479185ce9f65b9b2df8001872a1a365dae6b40da0
MD5 507fb18eeca85007c6b51bd7429c3476
BLAKE2b-256 fb33bd08b457a0372b2093286eb93a325d3006723a1033a6bfcdf1a8e13b4037

See more details on using hashes here.

File details

Details for the file clarifindata-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: clarifindata-0.2.7-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

Hashes for clarifindata-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 56e288a8acceefdbce52d94094e8e7c91028c5cbfe96ccfd4f7027772f226279
MD5 3e35c1362296da60533dfc568e995c85
BLAKE2b-256 1a87b606e98db0a69bd48ed547c6eb7ba486f2bc711b5e3f04d137cfc938811c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page