Skip to main content

tokease

词易算力指数平台的 Python SDK。不发请求也能查看每个接口的输入参数和输出字段;配置 API Key 后可以查询 index_basicindex_dailyindex_quotetrade_cal,以及无需 Key 的公开行情接口。

安装

发布到 PyPI 之后:

pip install tokease
pip install "tokease[pandas]"

在仓库里开发:

pip install -e python/tokease

查看接口参数

import tokease

tokease.apis()
tokease.apis("query")
tokease.api_params("index_daily")
tokease.api_fields("index_daily")
tokease.describe("index_quote")

api_params 返回的名称与 POST /api/v1/query 的参数白名单一致。未知参数会在本地直接拒绝,不会发给服务端。

查询数据

import tokease

client = tokease.Client(api_key="tokease_xxxxxxxxxxxx_xxxxxxxx")
frame = client.index_daily(
    index_code="Server_Index",
    start_date="20260801",
    end_date="20260831",
    fields=["trade_date", "index_code", "index_value", "change_rate"],
).to_dataframe()

API Key 也可以通过环境变量 TOKEASE_API_KEY 传入。服务地址是 pyproject.toml 里的 Homepage,当前为 https://whale.tokease.cn

默认会按 has_more 自动翻页。只要单页时传入 paginate=False

公开接口不需要 API Key:

client = tokease.Client()
client.public_indices()
client.public_index_latest("Server_Index")

发布到 PyPI

版本号始终等于仓库根目录 package.jsonversion,不要在 Python 包里另写一份。PyPI 上每个版本只能上传一次。

发布使用 PyPI API Token,不使用 GitHub 受信发布。在 PyPI 账号设置里创建令牌,范围选 Entire account,再写入本仓库的 Actions secret PYPI_API_TOKEN。之后推送与系统版本一致的标签即可发布。本地 .githooks/pre-push 会先核对,版本不一致时标签推不上去:

git tag v1.13.1
git push origin v1.13.1

也可以在 GitHub Actions 里手动运行 Publish tokease,选择 pypitestpypi。TestPyPI 需要在 test.pypi.org 另建一个 API Token,并换成对应的 secret。

Release files for tokease 1.13.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tokease 1.13.2
File Size Uploaded
tokease-1.13.2.tar.gz 15.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tokease 1.13.2
File Interpreter ABI Platform
tokease-1.13.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.3 kB

Release files / tokease-1.13.2.tar.gz

Download URL tokease-1.13.2.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
19e8fd641b25a0c0112d973a5220ec32e63d40e7ff9ab732e332d6a859002edb
BLAKE2b-256 checksum
How to use checksums
918b9f9a86768c8344e141dabb441cb8da449c351a21de3f19edc0a5b5e62ae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / tokease-1.13.2-py3-none-any.whl

Download URL tokease-1.13.2-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7c9cdb56d1b41652ed0fb71d696ff351dcfe5f85741da3646e5ef299693a6cb
BLAKE2b-256 checksum
How to use checksums
a021a43d5de93e11aab6a8c0e321d9a3d11b7be31cafccaa70a7262bba68fdfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

1.14.2

2 release files

1.14.1

2 release files

1.14.0

2 release files

This release

1.13.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page