uapi-sdk-python 0.1.14__tar.gz → 0.1.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uapi-sdk-python
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: Idiomatic UAPI SDK for Python
5
5
  Author-email: UAPI <dev@uapis.cn>
6
6
  Requires-Python: >=3.9
@@ -33,12 +33,10 @@ pip install uapi-sdk-python
33
33
  from uapi import UapiClient
34
34
 
35
35
  client = UapiClient("https://uapis.cn", "YOUR_API_KEY")
36
- result = client.misc.get_misc_hotboard(type="weibo")
36
+ result = client.social.get_social_qq_userinfo(qq="10001")
37
37
  print(result)
38
38
  ```
39
39
 
40
- 这个接口默认只要传 `type` 就可以拿当前热榜。`time`、`keyword`、`time_start`、`time_end`、`limit`、`sources` 都是按场景再传的可选参数。
41
-
42
40
  > [!TIP]
43
41
  > 请使用与运行脚本相同的 Python 解释器安装依赖,例如执行 `python -m pip install uapi-sdk-python` 后再运行 `python main.py`。在 VS Code / Pyright 中若提示 “Import uapi could not be resolved”,将解释器切换到当前虚拟环境即可恢复补全。
44
42
 
@@ -56,60 +54,6 @@ print(result)
56
54
 
57
55
  如果你需要查看字段细节或内部逻辑,仓库中的 `./internal` 目录同步保留了由 `openapi-generator` 生成的完整结构体,随时可供参考。
58
56
 
59
- ## 响应元信息
60
-
61
- 每次请求完成后,SDK 会自动把响应 Header 解析成结构化的 `ResponseMeta`,你不用自己拆原始字符串。
62
-
63
- 成功时可以通过 `client.last_response_meta` 读取,失败时可以通过 `err.meta` 读取,两条路径拿到的是同一套字段。
64
-
65
- ```python
66
- from uapi import UapiClient, UapiError
67
-
68
- client = UapiClient("https://uapis.cn", "YOUR_API_KEY")
69
-
70
- # 成功路径
71
- client.social.get_social_qq_userinfo(qq="10001")
72
- meta = client.last_response_meta
73
- if meta:
74
- print("这次请求原价:", meta.credits_requested or 0, "积分")
75
- print("这次实际扣费:", meta.credits_charged or 0, "积分")
76
- print("特殊计价:", meta.credits_pricing or "原价")
77
- print("余额剩余:", meta.balance_remaining_cents or 0, "分")
78
- print("资源包剩余:", meta.quota_remaining_credits or 0, "积分")
79
- print("当前有效额度桶:", meta.active_quota_buckets or 0)
80
- print("额度用空即停:", meta.stop_on_empty)
81
- print("Key QPS:", meta.billing_key_rate_remaining or 0, "/", meta.billing_key_rate_limit or 0, meta.billing_key_rate_unit or "req")
82
- print("Request ID:", meta.request_id)
83
-
84
- # 失败路径
85
- try:
86
- client.social.get_social_qq_userinfo(qq="10001")
87
- except UapiError as err:
88
- if err.meta:
89
- print("Retry-After 秒数:", err.meta.retry_after_seconds)
90
- print("Retry-After 原始值:", err.meta.retry_after_raw)
91
- print("访客 QPS:", err.meta.visitor_rate_remaining or 0, "/", err.meta.visitor_rate_limit or 0)
92
- print("Request ID:", err.meta.request_id)
93
- ```
94
-
95
- 常用字段一览:
96
-
97
- | 字段 | 说明 |
98
- |------|------|
99
- | `credits_requested` | 这次请求原本要扣多少积分,也就是请求价 |
100
- | `credits_charged` | 这次请求实际扣了多少积分 |
101
- | `credits_pricing` | 特殊计价原因,例如缓存半价 `cache-hit-half-price` |
102
- | `balance_remaining_cents` | 账户余额剩余(分) |
103
- | `quota_remaining_credits` | 资源包剩余积分 |
104
- | `active_quota_buckets` | 当前还有多少个有效额度桶参与计费 |
105
- | `stop_on_empty` | 额度耗尽后是否直接停止服务 |
106
- | `retry_after_seconds` / `retry_after_raw` | 限流后的等待时长;当服务端返回 HTTP 时间字符串时看 `retry_after_raw` |
107
- | `request_id` | 请求唯一 ID,排障时使用 |
108
- | `billing_key_rate_limit` / `billing_key_rate_remaining` | Billing Key 当前 QPS 规则的上限与剩余 |
109
- | `billing_ip_rate_limit` / `billing_ip_rate_remaining` | Billing Key 单 IP 当前 QPS 规则的上限与剩余 |
110
- | `visitor_rate_limit` / `visitor_rate_remaining` | 访客当前 QPS 规则的上限与剩余 |
111
- | `rate_limit_policies` / `rate_limits` | 完整结构化限流策略数据 |
112
-
113
57
  ## 进阶实践
114
58
 
115
59
  ### 缓存与幂等
@@ -19,12 +19,10 @@ pip install uapi-sdk-python
19
19
  from uapi import UapiClient
20
20
 
21
21
  client = UapiClient("https://uapis.cn", "YOUR_API_KEY")
22
- result = client.misc.get_misc_hotboard(type="weibo")
22
+ result = client.social.get_social_qq_userinfo(qq="10001")
23
23
  print(result)
24
24
  ```
25
25
 
26
- 这个接口默认只要传 `type` 就可以拿当前热榜。`time`、`keyword`、`time_start`、`time_end`、`limit`、`sources` 都是按场景再传的可选参数。
27
-
28
26
  > [!TIP]
29
27
  > 请使用与运行脚本相同的 Python 解释器安装依赖,例如执行 `python -m pip install uapi-sdk-python` 后再运行 `python main.py`。在 VS Code / Pyright 中若提示 “Import uapi could not be resolved”,将解释器切换到当前虚拟环境即可恢复补全。
30
28
 
@@ -42,60 +40,6 @@ print(result)
42
40
 
43
41
  如果你需要查看字段细节或内部逻辑,仓库中的 `./internal` 目录同步保留了由 `openapi-generator` 生成的完整结构体,随时可供参考。
44
42
 
45
- ## 响应元信息
46
-
47
- 每次请求完成后,SDK 会自动把响应 Header 解析成结构化的 `ResponseMeta`,你不用自己拆原始字符串。
48
-
49
- 成功时可以通过 `client.last_response_meta` 读取,失败时可以通过 `err.meta` 读取,两条路径拿到的是同一套字段。
50
-
51
- ```python
52
- from uapi import UapiClient, UapiError
53
-
54
- client = UapiClient("https://uapis.cn", "YOUR_API_KEY")
55
-
56
- # 成功路径
57
- client.social.get_social_qq_userinfo(qq="10001")
58
- meta = client.last_response_meta
59
- if meta:
60
- print("这次请求原价:", meta.credits_requested or 0, "积分")
61
- print("这次实际扣费:", meta.credits_charged or 0, "积分")
62
- print("特殊计价:", meta.credits_pricing or "原价")
63
- print("余额剩余:", meta.balance_remaining_cents or 0, "分")
64
- print("资源包剩余:", meta.quota_remaining_credits or 0, "积分")
65
- print("当前有效额度桶:", meta.active_quota_buckets or 0)
66
- print("额度用空即停:", meta.stop_on_empty)
67
- print("Key QPS:", meta.billing_key_rate_remaining or 0, "/", meta.billing_key_rate_limit or 0, meta.billing_key_rate_unit or "req")
68
- print("Request ID:", meta.request_id)
69
-
70
- # 失败路径
71
- try:
72
- client.social.get_social_qq_userinfo(qq="10001")
73
- except UapiError as err:
74
- if err.meta:
75
- print("Retry-After 秒数:", err.meta.retry_after_seconds)
76
- print("Retry-After 原始值:", err.meta.retry_after_raw)
77
- print("访客 QPS:", err.meta.visitor_rate_remaining or 0, "/", err.meta.visitor_rate_limit or 0)
78
- print("Request ID:", err.meta.request_id)
79
- ```
80
-
81
- 常用字段一览:
82
-
83
- | 字段 | 说明 |
84
- |------|------|
85
- | `credits_requested` | 这次请求原本要扣多少积分,也就是请求价 |
86
- | `credits_charged` | 这次请求实际扣了多少积分 |
87
- | `credits_pricing` | 特殊计价原因,例如缓存半价 `cache-hit-half-price` |
88
- | `balance_remaining_cents` | 账户余额剩余(分) |
89
- | `quota_remaining_credits` | 资源包剩余积分 |
90
- | `active_quota_buckets` | 当前还有多少个有效额度桶参与计费 |
91
- | `stop_on_empty` | 额度耗尽后是否直接停止服务 |
92
- | `retry_after_seconds` / `retry_after_raw` | 限流后的等待时长;当服务端返回 HTTP 时间字符串时看 `retry_after_raw` |
93
- | `request_id` | 请求唯一 ID,排障时使用 |
94
- | `billing_key_rate_limit` / `billing_key_rate_remaining` | Billing Key 当前 QPS 规则的上限与剩余 |
95
- | `billing_ip_rate_limit` / `billing_ip_rate_remaining` | Billing Key 单 IP 当前 QPS 规则的上限与剩余 |
96
- | `visitor_rate_limit` / `visitor_rate_remaining` | 访客当前 QPS 规则的上限与剩余 |
97
- | `rate_limit_policies` / `rate_limits` | 完整结构化限流策略数据 |
98
-
99
43
  ## 进阶实践
100
44
 
101
45
  ### 缓存与幂等
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "uapi-sdk-python"
7
- version = "0.1.14"
7
+ version = "0.1.16"
8
8
  description = "Idiomatic UAPI SDK for Python"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"