Skip to main content

koreantrain

Unified Python API for Korean train reservation — supports both SRT and KTX (Korail) with a single interface.

Installation

pip install koreantrain

Usage

from koreantrain import SRTService, KorailService, Passenger

# SRT
srt = SRTService("id", "pw")
trains = srt.search("수서", "부산", "20260301", "140000", time_limit="200000")
reservation = srt.reserve(trains[0], passengers=[Passenger.adult(2)])
print(reservation)  # [SRT] 03월 01일, 수서~부산(14:00~16:30) 53700원(2석), 구입기한 ...

# Korail (KTX) — same interface
korail = KorailService("id", "pw", train_type="ktx")
trains = korail.search("서울", "부산", "20260301", "140000", time_limit="200000")
reservation = korail.reserve(trains[0], passengers=[Passenger.adult(2)])

# Cancel
srt.cancel(reservation)

Passenger Types

Passenger.adult(count=1)
Passenger.child(count=1)
Passenger.senior(count=1)
Passenger.toddler(count=1)  # Korail only

Seat Type

from koreantrain import SeatType

srt.reserve(train, seat_type=SeatType.SPECIAL_FIRST)
# GENERAL_FIRST (default), GENERAL_ONLY, SPECIAL_FIRST, SPECIAL_ONLY

Error Handling

from koreantrain import LoginError, SoldOutError, NetworkError, ReservationError

try:
    srt.reserve(train)
except SoldOutError:
    print("매진")
except LoginError:
    print("로그인 만료")
except NetworkError:
    print("네트워크 오류")

Dependencies

Metadata

Release files for koreantrain 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 koreantrain 0.1.0
File Size Uploaded
koreantrain-0.1.0.tar.gz 5.2 kB Details

Built distribution (wheel)

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

Total release size: 11.5 kB

Release files / koreantrain-0.1.0.tar.gz

Download URL koreantrain-0.1.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a18c9b220d641a3bb105c53c2186bd4314e855633a228242b9048c6b49b5ca4c
BLAKE2b-256 checksum
How to use checksums
6b0f420c2ed9bf8220bb0cc072062a480fddf554c28cc46e5219eae86e9a4acf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

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

Download URL koreantrain-0.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68545173cef8f97119f2294e426f67bfb4cd4c8ae78e0414a283653f03a24b0b
BLAKE2b-256 checksum
How to use checksums
fb075b9b448a270bf112b0909c4f38bef087596a2da80d86da96b5b33a50afa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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