Name | yuuz12-sdk JSON |
Version |
0.1.5
JSON |
| download |
home_page | None |
Summary | Python 3 SDK for Yuuz12-Api. Check https://doc.yuuz12.top/web/#/5/ |
upload_time | 2024-05-28 17:20:57 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.11 |
license | MIT |
keywords |
yuuz12
shiruku
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Yuuz12-Api
> 文档地址: https://doc.yuuz12.top/web/#/5/
>
> PYPI 地址: https://pypi.org/project/yuuz12-sdk
>
> GitHub 仓库: https://github.com/NumberSir/yuuz12-sdk
## 简介
全异步编写,可调用 Yuuz12-Api。需要 Python 3.11+
安装:
```pip install yuuz12-sdk```
## 使用说明
1. 在项目根目录下新建 `.env` 文件,并在其中填写环境变量:
```env
API_VERSION=2 # API 版本,可不填,默认为 2
API_KEY_V1=your_api_key # v1 API 密钥
API_KEY_V2=your_api_key # v2 API 密钥
```
2. 请使用 `httpx` 库进行 API 异步调用,使用 `python-dotenv` 库读取环境变量
3. 传入初始化 client 实例化 API 类,并调用对应的 API:
```python
import asyncio
import httpx
import os
from dotenv import load_dotenv
from yuuz12_sdk.apis import User
load_dotenv()
async def main():
async with httpx.AsyncClient() as client:
"""实例化 API 类"""
user = User(client)
# 若 API 版本为 v1:
# user = User(client, version=1)
"""调用 API 方法,需显示传入关键字参数"""
await user.get_user_info(qq=1234567)
"""获取 API 响应体"""
user.response: httpx.Response
"""获取 API 二进制返回信息,如返回图片的 API 可通过此属性获取图片二进制内容"""
user.raw: bytes
"""获取 API 响应是否出错,仅能判断对 API 的调用是否出错,不能判断网络请求本身是否出错"""
user.error: bool
"""以下值仅在该 API 有 json 格式返回信息时才有意义,否则均为 None 或空字典"""
"""获取 API json 格式返回信息,默认为空字典"""
user.raw_data: dict
"""获取 API json 格式返回信息中的具体数据,如 get_user_info 返回数据中的 'user' 键对应值,默认为空字典"""
user.data: dict | list
"""获取 API json 格式返回信息中的响应代码,默认为 None"""
user.raw_code: int
"""获取 API json 格式返回信息中的响应信息,默认为 None"""
user.raw_msg: str
if __name__ == "__main__":
asyncio.run(main())
```
4. 使用示例:
```python
"""调用随机选择回声洞中回声信息"""
import asyncio
import httpx
from yuuz12_sdk.apis import Cave
async def main():
async with httpx.AsyncClient() as client:
cave = Cave(client)
await cave.get_cave()
data: dict = cave.data
qq: int = data["qq"]
string: str = data["string"]
time: str = data["time"]
if __name__ == '__main__':
asyncio.run(main())
```
```python
"""获取签到图片"""
import asyncio
import httpx
from yuuz12_sdk.apis import UserCheck
from yuuz12_sdk.models import UserModel
async def main():
async with httpx.AsyncClient() as client:
check = UserCheck(client)
await check.get(qq=1234567, favorability=1, coin=5)
image_binary: bytes = check.raw
if __name__ == '__main__':
asyncio.run(main())
```
Raw data
{
"_id": null,
"home_page": null,
"name": "yuuz12-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "Number_Sir <number_sir@126.com>",
"keywords": "yuuz12, shiruku",
"author": null,
"author_email": "Number_Sir <number_sir@126.com>",
"download_url": "https://files.pythonhosted.org/packages/ef/0e/f663b945458a2742b557e14293c94108d9af4e94306d597fcfd2451d38e0/yuuz12_sdk-0.1.5.tar.gz",
"platform": null,
"description": "# Yuuz12-Api\n> \u6587\u6863\u5730\u5740: https://doc.yuuz12.top/web/#/5/\n> \n> PYPI \u5730\u5740: https://pypi.org/project/yuuz12-sdk\n> \n> GitHub \u4ed3\u5e93: https://github.com/NumberSir/yuuz12-sdk\n\n## \u7b80\u4ecb\n\u5168\u5f02\u6b65\u7f16\u5199\uff0c\u53ef\u8c03\u7528 Yuuz12-Api\u3002\u9700\u8981 Python 3.11+\n\n\u5b89\u88c5\uff1a\n```pip install yuuz12-sdk```\n\n## \u4f7f\u7528\u8bf4\u660e\n1. \u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u65b0\u5efa `.env` \u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u586b\u5199\u73af\u5883\u53d8\u91cf\uff1a\n```env\nAPI_VERSION=2 # API \u7248\u672c\uff0c\u53ef\u4e0d\u586b\uff0c\u9ed8\u8ba4\u4e3a 2\nAPI_KEY_V1=your_api_key # v1 API \u5bc6\u94a5\nAPI_KEY_V2=your_api_key # v2 API \u5bc6\u94a5\n```\n2. \u8bf7\u4f7f\u7528 `httpx` \u5e93\u8fdb\u884c API \u5f02\u6b65\u8c03\u7528\uff0c\u4f7f\u7528 `python-dotenv` \u5e93\u8bfb\u53d6\u73af\u5883\u53d8\u91cf\n3. \u4f20\u5165\u521d\u59cb\u5316 client \u5b9e\u4f8b\u5316 API \u7c7b\uff0c\u5e76\u8c03\u7528\u5bf9\u5e94\u7684 API\uff1a\n```python\nimport asyncio\nimport httpx\nimport os\nfrom dotenv import load_dotenv\nfrom yuuz12_sdk.apis import User\n\nload_dotenv()\n\nasync def main():\n async with httpx.AsyncClient() as client:\n \"\"\"\u5b9e\u4f8b\u5316 API \u7c7b\"\"\"\n user = User(client)\n # \u82e5 API \u7248\u672c\u4e3a v1:\n # user = User(client, version=1)\n \n \"\"\"\u8c03\u7528 API \u65b9\u6cd5\uff0c\u9700\u663e\u793a\u4f20\u5165\u5173\u952e\u5b57\u53c2\u6570\"\"\"\n await user.get_user_info(qq=1234567)\n \n \"\"\"\u83b7\u53d6 API \u54cd\u5e94\u4f53\"\"\"\n user.response: httpx.Response\n \n \"\"\"\u83b7\u53d6 API \u4e8c\u8fdb\u5236\u8fd4\u56de\u4fe1\u606f\uff0c\u5982\u8fd4\u56de\u56fe\u7247\u7684 API \u53ef\u901a\u8fc7\u6b64\u5c5e\u6027\u83b7\u53d6\u56fe\u7247\u4e8c\u8fdb\u5236\u5185\u5bb9\"\"\"\n user.raw: bytes\n \n \"\"\"\u83b7\u53d6 API \u54cd\u5e94\u662f\u5426\u51fa\u9519\uff0c\u4ec5\u80fd\u5224\u65ad\u5bf9 API \u7684\u8c03\u7528\u662f\u5426\u51fa\u9519\uff0c\u4e0d\u80fd\u5224\u65ad\u7f51\u7edc\u8bf7\u6c42\u672c\u8eab\u662f\u5426\u51fa\u9519\"\"\"\n user.error: bool\n \n \"\"\"\u4ee5\u4e0b\u503c\u4ec5\u5728\u8be5 API \u6709 json \u683c\u5f0f\u8fd4\u56de\u4fe1\u606f\u65f6\u624d\u6709\u610f\u4e49\uff0c\u5426\u5219\u5747\u4e3a None \u6216\u7a7a\u5b57\u5178\"\"\"\n \"\"\"\u83b7\u53d6 API json \u683c\u5f0f\u8fd4\u56de\u4fe1\u606f\uff0c\u9ed8\u8ba4\u4e3a\u7a7a\u5b57\u5178\"\"\"\n user.raw_data: dict\n \n \"\"\"\u83b7\u53d6 API json \u683c\u5f0f\u8fd4\u56de\u4fe1\u606f\u4e2d\u7684\u5177\u4f53\u6570\u636e\uff0c\u5982 get_user_info \u8fd4\u56de\u6570\u636e\u4e2d\u7684 'user' \u952e\u5bf9\u5e94\u503c\uff0c\u9ed8\u8ba4\u4e3a\u7a7a\u5b57\u5178\"\"\"\n user.data: dict | list\n \n \"\"\"\u83b7\u53d6 API json \u683c\u5f0f\u8fd4\u56de\u4fe1\u606f\u4e2d\u7684\u54cd\u5e94\u4ee3\u7801\uff0c\u9ed8\u8ba4\u4e3a None\"\"\"\n user.raw_code: int\n \n \"\"\"\u83b7\u53d6 API json \u683c\u5f0f\u8fd4\u56de\u4fe1\u606f\u4e2d\u7684\u54cd\u5e94\u4fe1\u606f\uff0c\u9ed8\u8ba4\u4e3a None\"\"\"\n user.raw_msg: str\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n```\n4. \u4f7f\u7528\u793a\u4f8b:\n\n```python\n\"\"\"\u8c03\u7528\u968f\u673a\u9009\u62e9\u56de\u58f0\u6d1e\u4e2d\u56de\u58f0\u4fe1\u606f\"\"\"\nimport asyncio\nimport httpx\nfrom yuuz12_sdk.apis import Cave\n\n\nasync def main():\n async with httpx.AsyncClient() as client:\n cave = Cave(client)\n await cave.get_cave()\n \n data: dict = cave.data\n qq: int = data[\"qq\"]\n string: str = data[\"string\"]\n time: str = data[\"time\"]\n\nif __name__ == '__main__':\n asyncio.run(main())\n```\n\n```python\n\"\"\"\u83b7\u53d6\u7b7e\u5230\u56fe\u7247\"\"\"\nimport asyncio\nimport httpx\nfrom yuuz12_sdk.apis import UserCheck\nfrom yuuz12_sdk.models import UserModel\n\nasync def main():\n async with httpx.AsyncClient() as client:\n check = UserCheck(client)\n await check.get(qq=1234567, favorability=1, coin=5)\n \n image_binary: bytes = check.raw\n\nif __name__ == '__main__':\n asyncio.run(main())\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python 3 SDK for Yuuz12-Api. Check https://doc.yuuz12.top/web/#/5/ ",
"version": "0.1.5",
"project_urls": {
"Issues": "https://github.com/NumberSir/yuuz12-sdk/issues",
"Repository": "https://github.com/NumberSir/yuuz12-sdk"
},
"split_keywords": [
"yuuz12",
" shiruku"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5f4a4611207dd38c1086e579a5f79a73a7dc29d139f9e8b4ce2e959384596e75",
"md5": "eb935e9927e8a4a8079ee7a8305762d2",
"sha256": "96330fab02cd8fff39aa4aca2e9290651eee63f1fd60295bec14ff1b44ea4c46"
},
"downloads": -1,
"filename": "yuuz12_sdk-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb935e9927e8a4a8079ee7a8305762d2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 12972,
"upload_time": "2024-05-28T17:20:55",
"upload_time_iso_8601": "2024-05-28T17:20:55.318048Z",
"url": "https://files.pythonhosted.org/packages/5f/4a/4611207dd38c1086e579a5f79a73a7dc29d139f9e8b4ce2e959384596e75/yuuz12_sdk-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ef0ef663b945458a2742b557e14293c94108d9af4e94306d597fcfd2451d38e0",
"md5": "bf5e672ffcb5c595f7d53b963b9df774",
"sha256": "55e68b4c721da0df3ed035a734dca73c59a8629f4396109e9668a3dde6d44a63"
},
"downloads": -1,
"filename": "yuuz12_sdk-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "bf5e672ffcb5c595f7d53b963b9df774",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 8287,
"upload_time": "2024-05-28T17:20:57",
"upload_time_iso_8601": "2024-05-28T17:20:57.046804Z",
"url": "https://files.pythonhosted.org/packages/ef/0e/f663b945458a2742b557e14293c94108d9af4e94306d597fcfd2451d38e0/yuuz12_sdk-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-28 17:20:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "NumberSir",
"github_project": "yuuz12-sdk",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "yuuz12-sdk"
}