Skip to main content

Python SDK for Tianjian API platform

Project description

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 就什么时候启用。

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

tianjian_api-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

tianjian_api-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tianjian_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 037d402fbe75e22a773a8891fa99d300f02dbc2b033ce34d3d0b20e394ac5692
MD5 2185451e949fd6a54d2721595a55241c
BLAKE2b-256 9348a1581b67b8096f04fb6ad55b206c8584712f805b56950573be993e37c15a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tianjian_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a483352a3ab5ed963e64efe1509847ebabfba680c2e8239d3ef08f077dbf2ac
MD5 7ed1029269a068b290b634f482cddee4
BLAKE2b-256 d2023d32727c7c83f40331e92988c5fa72560f67197d2705e890af9ea5aeb932

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