빠른 시작
-
설치합니다. 버전은 정확히 고정하세요. 최신 버전 전체 목록은 GitHub Releases에 있습니다 (API 안정성).
Maven Central에서 배포하므로 저장소를 따로 추가하지 않습니다. Java 17 이상, Spring Boot 3.x.
dependencies {implementation "kr.suhsaechan:sejongpeia:<version>"}<dependency><groupId>kr.suhsaechan</groupId><artifactId>sejongpeia</artifactId><version><!-- 고정할 버전 --></version></dependency><version>에는 최신 버전을 넣으세요. Maven Central 아티팩트 페이지에서 확인하고, 전체 버전 목록은 저장소 목록에 있습니다.Python 3.9 이상, 표준 라이브러리 외 의존성이 없습니다.
터미널 창 pip install pro-sejongpeia==<version>Node 18 이상, 의존성 0개, TypeScript 타입 포함, ESM과 CommonJS 모두 지원합니다.
터미널 창 npm install pro-sejongpeia@<version> -
학생 인증을 호출합니다. 학번과 비밀번호로 통합 인증을 한 번 호출합니다.
Spring Boot 자동 설정이
SuhSejongAuthEngine빈을 등록합니다.@RestController@RequiredArgsConstructorpublic class AuthController {private final SuhSejongAuthEngine sejongAuthEngine;@PostMapping("/auth/sejong")public SejongAuthResult authenticate(@RequestParam String studentId,@RequestParam String password) {return sejongAuthEngine.authenticate(studentId, password);}}from sejongpeia import authenticate, SejongAuthError, ErrorCodetry:result = authenticate("21011234", "비밀번호")print(result.name, result.major, result.grade)except SejongAuthError as error:if error.code == ErrorCode.AUTHENTICATION_FAILED:print("학번 또는 비밀번호가 틀렸습니다")elif error.code == ErrorCode.ACCOUNT_LOCKED:print("포털 계정이 잠겼습니다. 포털에서 비밀번호를 재설정하세요")import { authenticate, SejongAuthError, ErrorCode } from 'pro-sejongpeia';try {const result = await authenticate('21011234', '비밀번호');console.log(result.name, result.major, result.grade);} catch (error) {if (error instanceof SejongAuthError && error.code === ErrorCode.AUTHENTICATION_FAILED) {console.log('학번 또는 비밀번호가 틀렸습니다');} else if (error instanceof SejongAuthError && error.code === ErrorCode.ACCOUNT_LOCKED) {console.log('포털 계정이 잠겼습니다. 포털에서 비밀번호를 재설정하세요');}}분기는 에러 메시지가 아니라 코드로 합니다. 코드 목록은 에러 코드입니다.
-
로그인 없이 쓰는 학교 데이터를 호출합니다. 학과 목록을 받고, 첫 학과의 개설강좌를 조회합니다 (학부).
"20"(학부)과 학기 값은 학교 값입니다.SejongPublicData publicData = new SejongPublicData(); // Spring에서는 빈으로 주입List<Department> departments = publicData.departments("20", "2026", "20");List<Lecture> lectures = publicData.lectures("20", "2026", "20", departments.get(0).getCode(), "", "");from sejongpeia import SejongPublicDatapublic_data = SejongPublicData()departments = public_data.departments("20", "2026", "20") # 학부, 학기 값은 학교 값lectures = public_data.lectures("20", "2026", "20", department_code=departments[0].code)# 강의의 과목 번호로 그 학과 교육과정의 학년·학기·교과목 개요 (없으면 빈 목록)courses = public_data.curriculum_courses(lectures[0].department_code, lectures[0].course_number)import { SejongPublicData } from 'pro-sejongpeia';const publicData = new SejongPublicData();const departments = await publicData.departments({ categoryCode: '20', year: '2026', semesterCode: '20' });const lectures = await publicData.lectures({ categoryCode: '20', year: '2026', semesterCode: '20', departmentCode: departments[0].code });SejongPublicData는 프로세스당 하나만 만드세요. 메모리 캐시(기본 24시간)와 같은 요청 합치기가 인스턴스 안에 있습니다.
일반 Java (Spring 없이)
섹션 제목: “일반 Java (Spring 없이)”Spring Boot는 선택 의존성이라 일반 Java 프로젝트는 받지 않습니다. 포털이 허용하는 오래된 TLS 암호를 JVM이 막고 있어서, main() 맨 앞에서 다른 HTTPS 호출보다 먼저 SejongTlsSupport.ensureLegacyCipherEnabled()를 불러야 합니다.
import kr.suhsaechan.sejongpeia.auth.client.SejongPortalClient;import kr.suhsaechan.sejongpeia.auth.client.SejongSisClient;import kr.suhsaechan.sejongpeia.auth.model.SejongAuthResult;import kr.suhsaechan.sejongpeia.auth.parser.SejongClassicReadingParser;import kr.suhsaechan.sejongpeia.auth.parser.SejongSisParser;import kr.suhsaechan.sejongpeia.auth.parser.SejongStudentInfoParser;import kr.suhsaechan.sejongpeia.auth.service.SuhSejongAuthEngine;import kr.suhsaechan.sejongpeia.common.config.SejongAuthProperties;import kr.suhsaechan.sejongpeia.common.util.SejongTlsSupport;
SejongTlsSupport.ensureLegacyCipherEnabled(); // main() 맨 앞, 다른 HTTPS 호출보다 먼저SejongAuthProperties properties = new SejongAuthProperties();SuhSejongAuthEngine engine = new SuhSejongAuthEngine(new SejongPortalClient(properties), new SejongStudentInfoParser(), new SejongClassicReadingParser(), new SejongSisClient(properties), new SejongSisParser());SejongAuthResult result = engine.authenticate(studentId, password);늦게 부르면 인증이 CONNECTION_FAILED와 원인 안내 메시지로 실패합니다. 이 설정은 JVM 전체에 적용됩니다. 자세한 이유는 레거시 TLS를 보세요. Spring Boot는 시작할 때 자동으로 처리하고, Python과 Node는 자기 연결의 TLS 설정만 바꿉니다.
