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 (81 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.6.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.6-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clarifindata-0.2.6.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.6.tar.gz
Algorithm Hash digest
SHA256 9f9afcceef029264885f260233deae86439acf4f88aae820b2f6cf6c6d8fbf8e
MD5 b54d0172ad468b4760bee72e440e4960
BLAKE2b-256 5dc7796d4fcaa8eff6ec7ee6780700c47efdd71b6893fae9748ae5d225fe4b49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clarifindata-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 12.4 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 21336de4fdb97e4a2502f93fda4d7fcaccce27278129a32c4249b96a860cb127
MD5 4e9853162ff11b60b2e94bd39b87d632
BLAKE2b-256 03bae5d3915e3d77fff9c7a0caee3a8218cc12e4313de230a7e17914486b8626

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