uapi-sdk-python
快速开始
pip install uapi-sdk-python
from uapi import UapiClient
client = UapiClient("https://uapis.cn", "YOUR_API_KEY")
result = client.social.get_social_qq_userinfo(qq="10001")
print(result)
特性
现在你不再需要反反复复的查阅文档了。
只需在 IDE 中键入 client.,所有核心模块——如 social、game、image——即刻同步展现。进一步输入即可直接定位到 get_social_qq_userinfo 这样的具体方法,其名称与文档的 operationId 严格保持一致,确保了开发过程的直观与高效。
所有方法签名只接受真实且必需的参数。当你在构建请求时,IDE 会即时提示 qq、username 等键名,这彻底杜绝了在 dict/关键字参数中因拼写错误而导致的运行时错误。
针对 401、404、429 等标准 HTTP 响应,SDK 已将其统一映射为具名的异常类型。这些异常均附带 code、status、details 等关键上下文信息,确保你在日志中能第一时间准确、快速地诊断问题。
UapiClient(base_url, token, timeout) 默认使用 httpx 并自动追加 Authorization 头;需要切换环境或调整超时时,只要改一次构造参数即可。
如果你需要查看字段细节或内部逻辑,仓库中的 ./internal 目录同步保留了由 openapi-generator 生成的完整结构体,随时可供参考。
进阶实践
缓存与幂等
from functools import lru_cache
from uapi import UapiClient
client = UapiClient("https://uapis.cn", token="YOUR_API_KEY")
@lru_cache(maxsize=128)
def cached_lookup(qq: str):
return client.social.get_social_qq_userinfo(qq=qq)
user = cached_lookup("10001")
也可以在 FastAPI / Django 项目里配合 Redis,将 SDK 的响应序列化后写入缓存,命中即直接返回。
调整超时与环境
from uapi import UapiClient
client = UapiClient(
"https://uapis.cn",
token="YOUR_API_KEY",
timeout=5.0,
)
如果你需要切换到别的环境,直接改 base_url 就可以;如果你只想缩短等待时间,传 timeout 就够了。
错误模型概览
| HTTP 状态码 | SDK 错误类型 | 附加信息 |
|---|---|---|
| 401/403 | UnauthorizedError |
code、status |
| 404 | NotFoundError / NoMatchError |
code、status |
| 400 | InvalidParameterError / InvalidParamsError |
code、status、details |
| 429 | ServiceBusyError |
code、status、retry_after_seconds(用于决定何时重试) |
| 5xx | InternalServerErrorError / ApiErrorError |
code、status、details |
| 其他 4xx | UapiError |
code、status、details |
其他 SDK
文档
访问 UApi文档首页 并选择任意接口,向下滚动到 快速启动 区块即可看到最新的 Python 示例代码。
Metadata
Release files for uapi-sdk-python 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uapi_sdk_python-0.1.18.tar.gz | 51.5 kB | Without provenance | Details for uapi_sdk_python-0.1.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uapi_sdk_python-0.1.18-py3-none-any.whl | Python 3 | none | any | Details for uapi_sdk_python-0.1.18-py3-none-any.whl |
Total release size: 100.4 kB
Release files / uapi_sdk_python-0.1.18.tar.gz
| Download URL | uapi_sdk_python-0.1.18.tar.gz |
|---|---|
| Size | 51.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f452503c952c64f337a1023322d7e4dc3a3bc082f225db1d97f3dbc3416ec3d
|
|
BLAKE2b-256 checksum How to use checksums |
af9bcbdab31fe5639c834290a4430bb8716754f445478e90bc382a500803a78a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / uapi_sdk_python-0.1.18-py3-none-any.whl
| Download URL | uapi_sdk_python-0.1.18-py3-none-any.whl |
|---|---|
| Size | 48.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
885986aad6f4ec34f836b250e24accf039883bc99c2e8ebda8e947b91c799e52
|
|
BLAKE2b-256 checksum How to use checksums |
e30d694079f0e1daddcf51114ff7903f0f7bc35767d6bbd5c96199854e6ac0d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for uapi-sdk-python 0.1.18
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.