Skip to main content

Devnors Data Python SDK

一个 API Key 调用所有数据 —— 面向 AI Agent 的高质量数据 API(法律等多领域官方权威数据,每条出处可回溯)。

安装

PyPI 正式发布进行中(打 sdk-v* tag 触发,见 docs/RELEASE.md)。发布后:

pip install devnors-data

发布前可用源码安装(从仓库根目录):

pip install -e ./sdk

快速开始

先在 开发者控制台 创建 API Key。

from devnors_data import DevnorsData

client = DevnorsData(api_key="devnors_sk_live_xxx")  # 或设环境变量 DEVNORS_API_KEY

# 裁判文书检索
res = client.legal_cases("民间借贷 利息", top_k=10)
for hit in res["hits"]:
    print(hit.get("case_no"), hit.get("title"))

# 法条检索
laws = client.legal_laws("合同解除 违约金")

# 统一入口(任意数据域/类型)
res = client.query(domain="legal", type="case", query="劳动争议", top_k=5)
print(res["units"], "tokens used")

异步:

import asyncio
from devnors_data import AsyncDevnorsData

async def main():
    client = AsyncDevnorsData(api_key="devnors_sk_live_xxx")
    res = await client.legal_cases("交通事故 责任认定")
    print(res["total_hits"])

asyncio.run(main())

自动重试与分页

  • 自动退避重试:429/5xx/连接级错误默认重试 2 次(指数退避 + 抖动,429 优先按 Retry-After);400/401/402/501 等不可重试错误绝不重试。关闭:DevnorsData(..., max_retries=0)(行为等同旧版)。
  • 分页遍历:paginate(...) 自动翻页(读 total_hits 判尽头),max_items 截断总量。
for hit in client.paginate("legal", "case", "借贷纠纷", page_size=20, max_items=100):
    print(hit.get("case_no"))

计费与错误

  • 按次调用计费,响应含 units(本次消耗 tokens)与 request_id。
  • 余额不足抛 DevnorsDataError(code="insufficient_balance", status=402);充值见控制台。
  • 触发限流抛 code="rate_limited"(429);数据源不可用 code="unavailable"(503,不计费)。
  • 每个 DevnorsDataError 携带 code / retryable / next_action / request_id,便于 Agent 自纠与报障对账。

数据域

domain type 状态
legal case / law_article / law_catalog 已上线
content / enterprise / research — 规划中(同一个 Key 上线即用)

Metadata

Release files for devnors-data 0.1.0

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

Source distribution (sdist)

Source distribution for devnors-data 0.1.0
File Size Uploaded Provenance Actions
devnors_data-0.1.0.tar.gz 9.0 kB Without provenance Details for devnors_data-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for devnors-data 0.1.0
File Interpreter ABI Platform Actions
devnors_data-0.1.0-py3-none-any.whl Python 3 none any Details for devnors_data-0.1.0-py3-none-any.whl

Total release size: 17.1 kB

Release files / devnors_data-0.1.0.tar.gz

Download URL devnors_data-0.1.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2c532fee8f3d957436cfd59cb444d88253c1592500bd4897323fa14c4d8ee6e5
BLAKE2b-256 checksum
How to use checksums
91c1578693e80fe8ac757e88454c6493ac27da24334c3011e581d2c981448e43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release files / devnors_data-0.1.0-py3-none-any.whl

Download URL devnors_data-0.1.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e03a67809847bbe1a0a45171328f4f6b6298b9e234b9751e7c23e25c273a692a
BLAKE2b-256 checksum
How to use checksums
b23ab6dc7cc42ba1b5d4c6e53be6476ada9a02e9f56e3217efbb76bf317d5fec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Security for devnors-data 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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