Skip to main content

Devnors Data Python SDK —— 一个 API Key 调用所有数据(法律等多领域官方权威数据)

Project description

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 上线即用)

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

devnors_data-0.1.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

devnors_data-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file devnors_data-0.1.0.tar.gz.

File metadata

  • Download URL: devnors_data-0.1.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for devnors_data-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2c532fee8f3d957436cfd59cb444d88253c1592500bd4897323fa14c4d8ee6e5
MD5 1d05a8c91a0205e8595c4b6cd555d8d1
BLAKE2b-256 91c1578693e80fe8ac757e88454c6493ac27da24334c3011e581d2c981448e43

See more details on using hashes here.

File details

Details for the file devnors_data-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: devnors_data-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for devnors_data-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e03a67809847bbe1a0a45171328f4f6b6298b9e234b9751e7c23e25c273a692a
MD5 8d964adbae8ba606cf220895ca67ae3f
BLAKE2b-256 b23ab6dc7cc42ba1b5d4c6e53be6476ada9a02e9f56e3217efbb76bf317d5fec

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