Skip to main content

The Python TJU client — scrapes TJU SSO + EAMS for structured academic data

Project description

TJU The Python TJU client

PyPI version CI Docs License: GPL v3

English | 简体中文

Beta release (v0.1.0). The API is functional; minor breaking changes may occur before v1.0.

tju is a Python library that logs into Tianjin University's SSO and EAMS systems and returns structured academic data. It handles CAS authentication, CAPTCHA solving (via ddddocr), and HTML parsing — so your code just calls methods and gets typed objects back.

Network requirement: All live API calls require an active connection to the TJU campus network or VPN (sso.tju.edu.cn / classes.tju.edu.cn).

Features

Feature Client method
Student profile client.profile
Personal timetable client.schedule(semester)
Public course library client.query_courses(semester)
Course detail client.query_course_info(lession_id)
Course syllabus client.query_syllabus(lession_id)
Exam schedule client.exam(semester)
Scores (UG + GS) client.score()
Experiment scores client.exp_score(semester)
Free classroom search client.free_classrooms(date_begin, ...)

Installation

pip install tju

From source (recommended for development):

git clone https://github.com/superpung/tju-python.git
cd tju-python
uv sync       # installs all dependencies into .venv

Quick start

Set your credentials as environment variables (or put them in a .env file):

export TJU_USER=your_student_id
export TJU_PASS=your_password
from tju.client import create_client

client = create_client()   # reads TJU_USER / TJU_PASS from env
print(client.profile)
print(client.schedule(semester="24251"))

Runnable examples:

# Personal timetable — prints your courses and saves JSON
uv run --env-file .env python examples/fetch_schedule.py

# Full course library (UG + GS) — crawls all pages and saves JSON
uv run --env-file .env python examples/fetch_all_courses.py

Both scripts write output to examples/output/ (gitignored).

Usage

from tju import Session
from tju.client import Client

session = Session()                              # or: Session(username=..., password=...)
client  = Client(session=session)

# Identity
client.stu_id        # student ID string
client.stu_name      # name string
client.stu_type      # StuType.UNDERGRADUATE | StuType.GRADUATE
client.has_minor     # bool
client.semester      # current semester code, e.g. "24252"

# Data
client.profile
client.schedule(semester="24251")
client.query_courses(semester="24251")
client.query_course_info(lession_id="387248")
client.query_syllabus(lession_id="387248")
client.exam(semester="24251")
client.score()
client.exp_score(semester="20211")
client.free_classrooms(date_begin="2025-10-08", campus_id=3)

Semester codes follow the EAMS convention, e.g. "24251" = 2024–2025 first term, "24252" = 2024–2025 second term. See src/tju/consts.py for the full SEMESTER map.

Development

uv sync          # install runtime + dev dependencies
uv run pytest    # run the offline test suite (30 tests, no network required)

See CONTRIBUTING.md for architecture details and the fixture privacy rule. See AGENTS.md for AI-agent contributor guidance.

Documentation

Full API reference and usage guides: https://superpung.github.io/tju-python/

To build the docs locally:

uv sync --group docs
uv run mkdocs serve

License

GPLv3 License © 2023-PRESENT Super Lee

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

tju-0.1.1.tar.gz (273.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tju-0.1.1-py3-none-any.whl (47.5 kB view details)

Uploaded Python 3

File details

Details for the file tju-0.1.1.tar.gz.

File metadata

  • Download URL: tju-0.1.1.tar.gz
  • Upload date:
  • Size: 273.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tju-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d98274803933a6412f7359584fa129285bc3d795ed4ede764eeb10a7a52c0c96
MD5 af05ba20f976ed215e9536cda0cf4919
BLAKE2b-256 d906d7424a9abd65d414be11e67ca13fa97fcddfd64b34c3be7c0082ef4831b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for tju-0.1.1.tar.gz:

Publisher: publish.yml on superpung/tju-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tju-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tju-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 47.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tju-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 beb6a15d5102087cea1224983f3e807276550af992e488f997a973d6b463d7b3
MD5 9a58dc18656d14cf041722e96243f32a
BLAKE2b-256 be6380e011b9f781200e7133259e74dd05d57019d4fb81b4cf5f75a304b1489d

See more details on using hashes here.

Provenance

The following attestation bundles were made for tju-0.1.1-py3-none-any.whl:

Publisher: publish.yml on superpung/tju-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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