Skip to main content

Python 3 SDK for Yuuz12-Api. Check https://doc.yuuz12.top/web/#/5/23

Project description

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 文件,并在其中填写环境变量:
API_VERSION=2            # API 版本,可不填,默认为 2
API_KEY_V1=your_api_key  # v1 API 密钥
API_KEY_V2=your_api_key  # v2 API 密钥
  1. 请使用 httpx 库进行 API 异步调用,使用 python-dotenv 库读取环境变量
  2. 传入初始化 client 实例化 API 类,并调用对应的 API:
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())
  1. 使用示例:
"""调用随机选择回声洞中回声信息"""
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())
"""获取签到图片"""
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())

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

yuuz12_sdk-0.1.4.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

yuuz12_sdk-0.1.4-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file yuuz12_sdk-0.1.4.tar.gz.

File metadata

  • Download URL: yuuz12_sdk-0.1.4.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.15.3 CPython/3.11.9 Windows/10

File hashes

Hashes for yuuz12_sdk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b00de9671a7ac750b7d39a86aa8c050c57d7a4125b3b980587999219a0b46bc1
MD5 58756e07df21ddc484d582089c7c0a7e
BLAKE2b-256 2f48ee9c1978a9f214d6d111828886e0962906e16e841ac827e8ced6fabd6f31

See more details on using hashes here.

File details

Details for the file yuuz12_sdk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: yuuz12_sdk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.15.3 CPython/3.11.9 Windows/10

File hashes

Hashes for yuuz12_sdk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3245fb3a8f520e4e842d89afed40e7e034705a15f003ef3266daab185e2ae1f2
MD5 c999d0ffa71e79dbc2242e8d876c571d
BLAKE2b-256 962b2e1385e60a6fe41f73b369320d02cd6939966e820c092f423b49ecf64a17

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page