nowkey
DataApi 数据集 Python SDK:SK + HMAC-SHA256 签名,覆盖数据集增删改查、聚合与旧 datasetApi 的全部调用形态。
安装
pip install nowkey
从源码开发:
cd sdk/python
pip install -e .
要求 Python 3.8+,依赖 requests。
5 分钟接入
- 在控制台或调用
POST /market/sk_create签发 SK,保存access_key与secret(Secret 只出现一次)。 - 配置环境变量或显式传参:
export DATAAPI_BASE_URL=http://127.0.0.1:5069
export DATAAPI_ACCESS_KEY=sk_xxx
export DATAAPI_SECRET=...
- 调用:
from nowkey import DataApi
with DataApi() as api:
print(api.get_list('wai_user', size=2))
print(api.count('wai_user'))
可执行示例见仓库 sdk/python/examples/quickstart.py:
python examples/quickstart.py wai_user 1
常用方法
| 方法 | 对应 /dataset/* |
|---|---|
get_list / get_info / count |
getlist / getinfo / count |
add / update / remove |
add / update / remove |
add_or_update(dataset, **fields) |
有 id 且存在则 update,否则 add |
add_or_remove(dataset, where, **fields) |
where 命中则 remove,否则 add |
func(dataset, **param) |
func |
aggregate / sum / inc / query |
aggregate |
iter_list(dataset, size=200, **filters) |
逐页拉取生成器 |
pull(dataset, **param) / iter_pull(...) |
/openapi/v1/pull 增量拉取(需 api_token) |
返回值保持服务端原始结构 {'code', 'msg', 'data'}(列表另带 total/size/p),网络失败重试耗尽返回 code 17。
迁移:替换旧 datasetApi.py
| 旧方法 | 新方法 |
|---|---|
getList(ds, param) |
get_list(ds, **param) |
getInfo / count / addInfo / setInfo / remove |
get_info / count / add / update / remove |
addSetInfo |
add_or_update |
addRmoveInfo |
add_or_remove |
aggregate / sum / incordec / query |
aggregate / sum / inc / query |
func |
func |
frame / config |
不提供(/frame/* 仍用明文 _dtoken) |
同步数据时用增量拉取(需开放网关的 API Token):
api = DataApi(base_url='http://127.0.0.1:5069', api_token='<api_token>')
for row in api.iter_pull('wai_user', mode='updatetime', since='2026-11-20 00:00:00'):
upsert(row) # at-least-once:被更新的行可能重投,按主键幂等写入
迁移期可用明文模式(服务端未关闭 DATAAPI_SK_ALLOW_PLAINTEXT 时):
api = DataApi(base_url='http://127.0.0.1:5069', token='平台用户或应用 Token')
测试
/usr/bin/python3 -m unittest discover -s sdk/python/tests -v
tests/test_client.py 覆盖签名、分页、重试、写语义与聚合;tests/test_examples.py 对示例做冒烟(注入假客户端)。
Metadata
Release files for nowkey 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nowkey-0.2.0.tar.gz | 8.2 kB | Without provenance | Details for nowkey-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nowkey-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for nowkey-0.2.0-py3-none-any.whl |
Total release size: 14.2 kB
Release files / nowkey-0.2.0.tar.gz
| Download URL | nowkey-0.2.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
673c9412e2cba643ab4ff59bfd53a99f388af80c041218b00b52fb411704bbb0
|
|
BLAKE2b-256 checksum How to use checksums |
4f44417ddea69558d2c604ec82736f1e7bbe225ef722dea5bc9703d8cac1dea7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Release files / nowkey-0.2.0-py3-none-any.whl
| Download URL | nowkey-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c787f2fdb766a075e64a3f9e20a7950de6522ef6c943ab9cc5773190fa965d0
|
|
BLAKE2b-256 checksum How to use checksums |
11aa2ae8ebca4b1af5c963b7a0ebab1950b05fc7035f94a0d3e251cb156b9086
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.7
|
Security for nowkey 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.