Skip to main content

ustc-sdk

中国科大校园系统的异步 Python SDK,要求 Python 3.11+。

提供显式账号、独立会话的统一认证、第二课堂、教务、学习空间和体育场馆客户端。 公开数据模型使用 Pydantic,支持 JSON 序列化与 JSON Schema。

安装(发布后)

uv add ustc-sdk

读取第二课堂活动

import asyncio
import os

from ustc_sdk import CASClient, YoungClient


async def main():
    async with CASClient(os.environ["USTC_USERNAME"], os.environ["USTC_PASSWORD"]) as cas:
        async with YoungClient(cas) as young:
            for activity in await young.list_activities(limit=5):
                print(activity.model_dump_json())


asyncio.run(main())

账号配置由应用负责;客户端不会自动查找其他工具的配置或共享全局账号状态。 CAS Cookie 保留原始域名、路径和 Secure 属性;各校园系统分别持有自己的应用会话。

模块

  • ustc_sdk.auth:CAS 认证与服务票据。
  • ustc_sdk.young:第二课堂列表、详情、已参与活动、报名与取消。
  • ustc_sdk.eams:课表、成绩、选退课与课程调整。
  • ustc_sdk.spaces:学习空间房间、成员、预约查询及写操作。
  • ustc_sdk.venue_booking:体育场馆查询与已有订单操作;创建预约所需的小程序设备验证字段未提供。

业务流程、存储和定时扫描由独立的 ustc-tools 包提供。 学习空间上游使用明文 HTTP;CAS 密码仅提交到 HTTPS 认证站点。 写操作出现 SubmissionUnknown 时需先查询服务器状态,不能直接重发。

来源与许可

MIT。认证、教务、二课与体育协议基于 pyustc v1.2.1, 学习空间协议基于 xtcli 固定快照。 原始许可和来源说明随包附带。

源码与完整文档

Metadata

Release files for ustc-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ustc-sdk 0.1.0
File Size Uploaded Provenance Actions
ustc_sdk-0.1.0.tar.gz 34.9 kB Without provenance Details for ustc_sdk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ustc-sdk 0.1.0
File Interpreter ABI Platform Actions
ustc_sdk-0.1.0-py3-none-any.whl Python 3 none any Details for ustc_sdk-0.1.0-py3-none-any.whl

Total release size: 80.3 kB

Release files / ustc_sdk-0.1.0.tar.gz

Download URL ustc_sdk-0.1.0.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
11c16c648ea48b08dfaef79a72336afd242d8d9d0399183a92160b98820d2ea9
BLAKE2b-256 checksum
How to use checksums
75b050f978d978b31ed906db89f145eb126925c48dc6c9786181a3c9fdd37216
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ustc_sdk-0.1.0-py3-none-any.whl

Download URL ustc_sdk-0.1.0-py3-none-any.whl
Size 45.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83c76957ea1faa3d97d1e65b85acd5a6779db2c7388bbd0cc569cf47d96d0b8c
BLAKE2b-256 checksum
How to use checksums
485eba73578fe7649f2ce27cc2c6967f891d4362f4c2b040ebd33c8d895398fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ustc-sdk 0.1.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page