Skip to main content

Korail

An unofficial Korail API for Python.

Installation

You can install Korail with pip command like below:

$ pip install korail

Quick Start

1. Login

You can login to korail server via membership number signing or phone number signing.

Basically, to login via membership number signing:

from korail import Korail

korail = Korail()
korail.login('12345678', '0000')  # membership number signing

Or via phone number signing:

korail.login('010-1234-5678', '0000', True)  # phone number siging

2. Search Station

Search a station code with station name. All station code and name data is stored in stations.py file in package.

A single station data looks like:

{
    "code": "0001",
    "name": u"서울"
}
stations = korail.search_station('서울')
print stations[0]['code']  # '0001'

3. Search Train

You can search train schedules with search_train() method. search_train() method takes these arguments:

dep

A departure station code.

arr

An arrival station code.

date

Departure date. (yyyyMMdd formatted)

time (Default=’000000’)

Departure time. (hhmmss formatted)

train (Default=’05’)

A train type. One of these:

  • 00: KTX

  • 01: 새마을호

  • 02: 무궁화호

  • 03: 통근열차

  • 04: 누리로

  • 05: 전체 (기본값)

  • 06: 공학직통

  • 09: ITX-청춘

count (Default=1)

A number of passengers. Minimum value is 1 and maximum is 9.

Sample search code:

dep = '0001'  # From: Seoul Station
arr = '0015'  # To: Dong-Daegu Station
date = '20140114'  # yyyyMMdd
time = '001230'  # hhmmss

# list of ``Trains`` instances.
trains = korail.search_train(dep, arr, date, time)

4. Reservation

try:
    korail.reserve(train)
except KorailError as e:
    print e.message

5. Get Tickets

Retrieving all ticket information is not support yet. Only ticket id is returned.

korail.tickets()

6. Cancel Ticket

Example code below cancels all reserved tickets.

for ticket_id in korail.tickets():
    korail.cancel_ticket(ticket_id)

To-Do

  1. Non-member reservation

  2. More detailed exception handling

  3. tickets() to return all ticket information.

Metadata

Release files for Korail 0.0.3

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

Source distribution (sdist)

Source distribution for Korail 0.0.3
File Size Uploaded Provenance Actions
Korail-0.0.3.tar.gz 9.6 kB Without provenance Details for Korail-0.0.3.tar.gz

Release files / Korail-0.0.3.tar.gz

Download URL Korail-0.0.3.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1ae3c1fb8544666efb0171c89f8c8f4086d408e80a825958ae01ddce3fb803b8
BLAKE2b-256 checksum
How to use checksums
a1d8ad8cb4e01c47b3defce2e7e8410277f4864935233d27c76d98570529fc66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for Korail 0.0.3

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.

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 release file No provenance

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