Skip to main content

kestrel-data-sdk

Kestrel Data 按需数据下载 SDK。适用于已获授权的 API 账户,无 Web UI、无常驻服务、 无自动下发,支持 Linux、macOS 和 Windows 的 Python 3.10+。

from kestrel_data_sdk import Kestrel

kd = Kestrel("api-user", "password")
print(kd.products())
kd.download("ods.wind.ashareeodprices", "/data/kestrel", start="202601", end="202608")

授权范围内没有下载次数配额。特定 API 账户还可由管理员开启“全部数据权限”。默认在输出 目录的 .kestrel/sdk-cache.sqlite3 记录已完成的发布版本。每次同步只把本地版本号集合提交给 服务端,由服务端立即返回不可变的 24 小时同步计划;只有需要更新的分区才逐个获取文件清单, 避免在首次下载前等待整批历史文件扫描。 需要主动重新下载时使用:

kd.download("ods.wind.ashareeodprices", "/data/kestrel", start="202608", end="202608", force=True)

下载默认在终端显示文件进度、已下载/总大小、速度和 ETA。非交互脚本可使用 progress=False 关闭。网络中断时会保留 .kestrel.part 临时文件并自动断点续传,默认最多尝试 5 次。

缓存查询和校验:

print(kd.cache_info("/data/kestrel"))

# 显式检查存在性、大小和修改时间;失效索引会被清除,下次下载自动补齐
print(kd.check_cache("/data/kestrel"))

# 精确检查会读取全部已缓存文件并重算 SHA-256
print(kd.check_cache("/data/kestrel", deep=True))

check_cache(..., repair=True) 只修复缓存索引,不会删除本地文件。特殊脚本可以使用 Kestrel(..., cache=False) 禁用持久缓存。

账户必须由管理员设为 API 工具。普通 API 账户受产品授权、数据范围和授权有效期约束; 开启“全部数据权限”的账户不受这些约束。

Metadata

Release files for kestrel-data-sdk 0.3.2

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

Built distribution (wheel)

Table of built distributions (wheels) for kestrel-data-sdk 0.3.2
File Interpreter ABI Platform
kestrel_data_sdk-0.3.2-py3-none-any.whl Python 3 none any Details

Release files / kestrel_data_sdk-0.3.2-py3-none-any.whl

Download URL kestrel_data_sdk-0.3.2-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16953a36c9a1415d01b75f3b0d121041c315636f403a2ce85a8b185fb0e2dad2
BLAKE2b-256 checksum
How to use checksums
b2d41a84d3e4057880a767229ea98fe49a018842f7557c1f4ddb44f6af6b46b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.3.3

1 release file

This release

0.3.2 This release

1 release file

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