Skip to main content

Tianjian API Python SDK

简洁同步版 SDK,适合服务端脚本、业务系统和定时任务接入。它是独立 Python 第三方库,不改变网站现有业务接口。

安装

pip install -e .

快速开始

from tianjian_api import TianjianClient

client = TianjianClient(
    api_key="你的 API KEY",
    base_url="https://ocr.ikunocr.cn",
    type="api",
    proxy="http://127.0.0.1:7890",  # SDK 请求平台时使用的网络代理,可不填
    timeout=10,
)

res = client.call("16hangzhoudxdx", c="xxx", api_proxy="http://user:pass@ip:port/")
print(res)

常用能力

  • client.call(path, **params) 调用任意产品接口,自动携带 key。
  • client.get(path, **params) 使用 GET 调用产品接口。
  • client.post(path, **params) 使用 POST 调用产品接口。
  • client.balance() 查询余额,需要平台提供 API KEY 查询接口后配置 balance_path。
  • client.packages() 查询当前用户套餐,需要平台提供 API KEY 查询接口后配置 packages_path。

注意:proxy 是 SDK 自己访问平台时使用的网络代理;api_proxy 是传给平台产品接口的业务代理参数,未传时不会发送该字段。

查询余额和套餐

如果后续平台开放查询接口,例如:

GET /api/account/balance/get?key=你的密钥
GET /api/account/packages/get?key=你的密钥

SDK 可以这样接入:

client = TianjianClient(
    api_key="你的 API KEY",
    base_url="https://ocr.ikunocr.cn",
    balance_path="account/balance",
    packages_path="account/packages",
)

print(client.balance())
print(client.packages())

这样第三方库保持独立,网站什么时候开放查询能力,SDK 就什么时候启用。

Metadata

Release files for tianjian-api 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 tianjian-api 0.1.0
File Size Uploaded Provenance Actions
tianjian_api-0.1.0.tar.gz 3.5 kB Without provenance Details for tianjian_api-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tianjian-api 0.1.0
File Interpreter ABI Platform Actions
tianjian_api-0.1.0-py3-none-any.whl Python 3 none any Details for tianjian_api-0.1.0-py3-none-any.whl

Total release size: 7.6 kB

Release files / tianjian_api-0.1.0.tar.gz

Download URL tianjian_api-0.1.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
037d402fbe75e22a773a8891fa99d300f02dbc2b033ce34d3d0b20e394ac5692
BLAKE2b-256 checksum
How to use checksums
9348a1581b67b8096f04fb6ad55b206c8584712f805b56950573be993e37c15a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.5

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

Download URL tianjian_api-0.1.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a483352a3ab5ed963e64efe1509847ebabfba680c2e8239d3ef08f077dbf2ac
BLAKE2b-256 checksum
How to use checksums
d2023d32727c7c83f40331e92988c5fa72560f67197d2705e890af9ea5aeb932
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.5

Security for tianjian-api 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