korail-mobile-api 2.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. korail_mobile_api-2.0.1/CHANGELOG.md +103 -0
  2. korail_mobile_api-2.0.1/LICENSE +202 -0
  3. korail_mobile_api-2.0.1/MANIFEST.in +15 -0
  4. korail_mobile_api-2.0.1/PKG-INFO +276 -0
  5. korail_mobile_api-2.0.1/README.md +237 -0
  6. korail_mobile_api-2.0.1/checks/ACCEPTANCE.md +27 -0
  7. korail_mobile_api-2.0.1/checks/BEHAVIOR.md +95 -0
  8. korail_mobile_api-2.0.1/checks/README.md +15 -0
  9. korail_mobile_api-2.0.1/checks/contract_api.py +275 -0
  10. korail_mobile_api-2.0.1/checks/netfunnel_offline.py +292 -0
  11. korail_mobile_api-2.0.1/pyproject.toml +91 -0
  12. korail_mobile_api-2.0.1/setup.cfg +4 -0
  13. korail_mobile_api-2.0.1/src/korail_mobile_api/__init__.py +477 -0
  14. korail_mobile_api-2.0.1/src/korail_mobile_api/_maas_unsupported.py +60 -0
  15. korail_mobile_api-2.0.1/src/korail_mobile_api/_parsing.py +254 -0
  16. korail_mobile_api-2.0.1/src/korail_mobile_api/_payload_helpers.py +32 -0
  17. korail_mobile_api-2.0.1/src/korail_mobile_api/_social_login_unsupported.py +47 -0
  18. korail_mobile_api-2.0.1/src/korail_mobile_api/_travel_search_unsupported.py +35 -0
  19. korail_mobile_api-2.0.1/src/korail_mobile_api/client.py +2001 -0
  20. korail_mobile_api-2.0.1/src/korail_mobile_api/config.py +102 -0
  21. korail_mobile_api-2.0.1/src/korail_mobile_api/constants.py +254 -0
  22. korail_mobile_api-2.0.1/src/korail_mobile_api/crypto.py +67 -0
  23. korail_mobile_api-2.0.1/src/korail_mobile_api/dynapath.py +412 -0
  24. korail_mobile_api-2.0.1/src/korail_mobile_api/errors.py +515 -0
  25. korail_mobile_api-2.0.1/src/korail_mobile_api/http.py +394 -0
  26. korail_mobile_api-2.0.1/src/korail_mobile_api/limousine_models.py +135 -0
  27. korail_mobile_api-2.0.1/src/korail_mobile_api/limousine_parsers.py +183 -0
  28. korail_mobile_api-2.0.1/src/korail_mobile_api/limousine_payloads.py +61 -0
  29. korail_mobile_api-2.0.1/src/korail_mobile_api/live.py +77 -0
  30. korail_mobile_api-2.0.1/src/korail_mobile_api/models.py +846 -0
  31. korail_mobile_api-2.0.1/src/korail_mobile_api/mutation_models.py +844 -0
  32. korail_mobile_api-2.0.1/src/korail_mobile_api/mutation_parsers.py +566 -0
  33. korail_mobile_api-2.0.1/src/korail_mobile_api/mutation_payloads.py +1453 -0
  34. korail_mobile_api-2.0.1/src/korail_mobile_api/netfunnel.py +351 -0
  35. korail_mobile_api-2.0.1/src/korail_mobile_api/netfunnel_safety.py +39 -0
  36. korail_mobile_api-2.0.1/src/korail_mobile_api/parsers.py +729 -0
  37. korail_mobile_api-2.0.1/src/korail_mobile_api/payloads.py +346 -0
  38. korail_mobile_api-2.0.1/src/korail_mobile_api/py.typed +0 -0
  39. korail_mobile_api-2.0.1/src/korail_mobile_api/read_models.py +1997 -0
  40. korail_mobile_api-2.0.1/src/korail_mobile_api/read_parsers.py +2805 -0
  41. korail_mobile_api-2.0.1/src/korail_mobile_api/read_payloads.py +1298 -0
  42. korail_mobile_api-2.0.1/src/korail_mobile_api/session.py +232 -0
  43. korail_mobile_api-2.0.1/src/korail_mobile_api.egg-info/SOURCES.txt +53 -0
  44. korail_mobile_api-2.0.1/tests/conftest.py +106 -0
  45. korail_mobile_api-2.0.1/tests/test_account_reads.py +1453 -0
  46. korail_mobile_api-2.0.1/tests/test_auth_transport.py +914 -0
  47. korail_mobile_api-2.0.1/tests/test_cleanup_queue_numbers.py +40 -0
  48. korail_mobile_api-2.0.1/tests/test_cleanup_refactoring.py +76 -0
  49. korail_mobile_api-2.0.1/tests/test_cleanup_regressions.py +184 -0
  50. korail_mobile_api-2.0.1/tests/test_cleanup_types.py +50 -0
  51. korail_mobile_api-2.0.1/tests/test_docs.py +111 -0
  52. korail_mobile_api-2.0.1/tests/test_mutations.py +2093 -0
  53. korail_mobile_api-2.0.1/tests/test_netfunnel_limousine.py +1304 -0
  54. korail_mobile_api-2.0.1/tests/test_packaging.py +258 -0
  55. korail_mobile_api-2.0.1/tests/test_public_api_smoke.py +541 -0
  56. korail_mobile_api-2.0.1/tests/test_train_reads.py +1373 -0
@@ -0,0 +1,103 @@
1
+ # 변경 이력
2
+
3
+ ## [2.0.1] - 2026-09-27
4
+
5
+ 코드는 2.0.0 과 같습니다.
6
+
7
+ - PyPI 에 올립니다. `pip install korail-mobile-api` 로 설치할 수 있습니다.
8
+ - README 의 이미지와 링크를 절대 주소로 바꿔 PyPI 페이지에서도 보이게 했습니다.
9
+ - 오류 처리 문서에 로그인의 `-2000` 차단이 접속한 네트워크의 IP 대역 때문에도 생길 수 있다는 안내를 더했습니다.
10
+
11
+ ## [2.0.0] - 2026-09-26
12
+
13
+ v1.1.1 이후의 변경입니다. 코레일+ 안드로이드 앱 7.0.6 기준이며, GitHub 릴리스로 공개하고 PyPI 에는 올리지 않습니다.
14
+ v1.0.0~v1.1.1 의 기록은
15
+ [v1.1.1 태그의 CHANGELOG](https://github.com/yakisoba0728/korail-mobile-api/blob/v1.1.1/CHANGELOG.md)에 있습니다.
16
+
17
+ ### 달라진 요청과 동작
18
+
19
+ - 요청 필드를 앱 DTO 의 선언 순서로 보냅니다(`NetworkService.java:15335–15392`). 로그인, 예약 5종, 환불·수수료 조회
20
+ (공통 필드를 맨 뒤), 호차 조회, 승차권 목록, 병합 조회가 해당하고, 요금 재계산은 Retrofit 목록 순서입니다. `lang` 은 `Key` 뒤에 옵니다.
21
+ - API 요청은 `User-Agent: korailtalk` 과 앱 OkHttp 기본 헤더(`Connection: Keep-Alive`, `Accept-Encoding: gzip`)를 보내고
22
+ `Accept` 는 보내지 않습니다.
23
+ - 대기열 요청은 빈 본문 POST 에 안드로이드 기본 Dalvik User-Agent(`Build/…` 포함)를 싣고, 응답 코드와 TTL·대기 인원은
24
+ Java `Integer.parseInt` 처럼 읽습니다. 허용 범위 밖 노드는 무시하고 정문으로 진행·반납합니다.
25
+ - DynaPath 토큰의 `rt` 에 요청 간 시간차(최근 5개)를 싣습니다. v1.1.1 은 `rt=0` 고정이었습니다.
26
+ - 운임 조회는 상품번호가 없어도 `gdNo` 칸을 보냅니다.
27
+ - 요청 전에 거절합니다: 카드 입력 형식, 0원·예약대기 홀드의 카드 결제, 수수료 조회 응답 없는 환불, 마일리지가 수수료보다 적은
28
+ 마일리지 정산, 탑승 순서가 아닌 환승 구간, 운행일이 다른 병합 행, 공항버스 좌석 중복.
29
+ - 좌석·호차·역의 선택 필드 18개가 빠지면 앱 기본값으로 읽습니다. 봉투와 String 필드의 JSON 정수는 문자열로 읽습니다.
30
+ 파싱에 실패하면 예외 `.raw` 에 전체 응답, `.parser_raw` 에 부분 원문이 남습니다.
31
+
32
+ ### 수정
33
+
34
+ - `refund`는 `commission`이 `get_refund_commission`의 응답이 아니면(`None` 포함) 요청 전에 `KorailProtocolError`로 거절합니다.
35
+ 전에는 `commission=None`을 명시하면 수수료 값 없이 환불 요청을 보냈습니다.
36
+ - 로그인 폼에서 `txtInputFlg`를 회원번호 앞, `custId`를 `checkValidPw` 앞에 둡니다
37
+ (`LoginIn.java:57–80,141–164`). 경로·필드·값·헤더는 유지합니다.
38
+ - 봉투와 `PriceRecalculationRequest.for_hold` 좌석의 과도하게 큰 JSON 정수도 원문을 보존한
39
+ `KorailProtocolError`로 거절합니다. 재계산 실패에는 좌석 원문도 `parser_raw`로 남깁니다.
40
+ - `BaseKorailResponse.from_raw`는 봉투의 JSON 정수를 문자열로 읽고 잘못된 타입은 원문과 함께 거절합니다.
41
+ 성공·실패 판정은 하지 않습니다.
42
+ - 지연확인증의 선택 `runDt`는 다른 선택 문자열처럼 잘못된 타입이면 `None`입니다.
43
+ - 대기열 TTL·대기 인원은 부호·BMP 십진 숫자·긴 선행 0을 Java int32처럼 읽습니다.
44
+ 잘못된 값은 기존의 0 기본값을 유지하며 큰 정수 변환의 `ValueError`가 새어 나오지 않습니다.
45
+ - 공통 파싱·요청·재시도 정책은 [동작 계약](https://github.com/yakisoba0728/korail-mobile-api/blob/main/checks/BEHAVIOR.md)에 모았습니다.
46
+
47
+ ### 타입
48
+
49
+ - `KorailLoginInputFlag`와 `KorailRoomClassCode` 입력 타입 별칭을 공개합니다.
50
+ 로그인 종류·비밀번호 확인 여부·객실 종류를 타입으로 좁히며 런타임 검증은 추가하지 않습니다.
51
+ - 공개 응답 모델의 `raw`는 `Mapping[str, object]`입니다. 실제 원문 객체를 복사·동결하거나 마스킹하지 않습니다.
52
+ - `BaseKorailResponse.from_raw`와 `TrainSummary.from_raw`의 반환형은 `Self`입니다.
53
+ 서버 응답 코드 필드는 `str`/`str | None`을 유지합니다.
54
+
55
+ ### 공개 API 추가
56
+
57
+ - 상품 예약 취소, 공항버스 예약, 역 발권 승차권 환불 검증·실행을 제공합니다:
58
+ `cancel_product_reservation`, `reserve_limousine`, `verify_station_ticket_refund`, `execute_station_ticket_refund`.
59
+ - 지연확인증·지연료 반환 영수증, 셀프 체크인 정보·좌석 확인·등록·취소, 전달 승차권 회수를 제공합니다:
60
+ `get_delay_certificate`, `get_delay_return_receipt`, `get_self_checkin_info`, `check_self_checkin_seat`,
61
+ `register_self_checkin`, `cancel_self_checkin`, `retrieve_delivered_ticket`.
62
+ - `PriceRecalculationRequest.for_hold`는 첫 여정 좌석별 재계산 행을 만듭니다.
63
+ `recalculate_price(add_to_cart=True)`는 재계산 성공 뒤 장바구니 추가를 요청하고 `cart_addition`에 결과를 남깁니다.
64
+ - `TrainSearchQuery`는 청소년·유아·안내견 인원도 받습니다. 조회 폼에서는 각각 어른·어린이·어른 인원에 합칩니다.
65
+ - `ReservationHoldResponse.payable`은 예약대기 결제를 막는 값입니다. 병합 첫 홀드는 결제할 수 있습니다.
66
+
67
+ ### v1.1.1 과 호환되지 않는 변경
68
+
69
+ 모델은 키워드 인자로 생성하십시오. 변경 메서드는 별도 사전 동의 없이 즉시 요청합니다.
70
+
71
+ - 제거 메서드: `get_gift_ticket_list`, `get_limousine_schedule_view`, `get_platform_numbers`, `pay_with_fake_card`.
72
+ - 제거 인자·이름: `consent=`, `MutationPreview`, `SELF_SEAT_CHANGE_ROOM_CLASS_CODES`, `inquiry_action`.
73
+ 제거 모듈: `consent`, `redaction`, `safety`.
74
+ `live_enabled`, `read_credentials_from_env`, `run_live_smoke_from_env`도 제거했습니다.
75
+ - `get_crew_request_list`는 `query_division_code` 대신 키워드 `timestamp_ms`를 받습니다.
76
+ `get_station_info`의 `device`, `refund`의 `return_times_division_code`는 제거했습니다.
77
+ - `refund`의 `commission`은 필수 키워드입니다. `reserve_merge`의 두 번째 인자 이름은 `merge_rows`입니다.
78
+ `get_ticket_receipt`의 식별값은 키워드 전용이며 `get_ticket_list`의 `page_no` 기본값은 `1`입니다.
79
+ - `get_ticket_list`, `refund`, `add_to_cart`는 각각 전용 `BaseKorailResponse` 하위 모델을 반환합니다.
80
+ - `KorailConfig.enable_dynapath`·`live_env_var`는 제거했습니다. DynaPath를 끄려면 `disable_dynapath=True`를 씁니다.
81
+ API의 `user_agent`와 대기열의 `netfunnel_user_agent`는 별도 설정입니다.
82
+ `build_dalvik_user_agent`는 키워드 `build_id`가 필요합니다.
83
+ - 제거 모델 필드: `AppDataResponse.for_seat_intg`·`airport_bus_msg`, `DelayDiscountTicket.usable_until_date`,
84
+ `DiscountCardScheduleTrain.station_string_info`, `DiscountCardSection.section_sequence`, `DiscountCoupon.discount_values`,
85
+ `MileageHistoryResponse.rail_now_saved_point_1`, `PriceFareLeg.standing_train_classification_code`,
86
+ `RefundTicketDetailResponse.mileage_save_flag`, `TrainSearchContinuation.page_count`,
87
+ `TrainSearchMetadata.merge_reservation_available_flag`, `TripChangeDateResponse.trip_change_date`,
88
+ `TripMenuContent.content_type`, `KorailAuthContinuationRequired.post_data`.
89
+ - `DiscountCoupon.discount_values` 대신 할인 구분·평일/주말 운임·요금 할인 속성을 사용합니다.
90
+ `StationInfoResponse.count`, `SeatInventoryResponse.layout_type`, `CartItem.ticket_count`,
91
+ `TicketDuplicationCheckResponse.reservation_count`, `KorailStation.popup_type`, `PassMenuItem.after_day`,
92
+ `TrainScheduleStop.actual_arrival_delay_count`는 문자열입니다.
93
+ - `PbpAcceptanceJourney.member_card_no`, `PriceFareLeg.train_class_code`, `TicketReceipt.printed_discount_kind_code`·
94
+ `ticket_kind_name`·`train_group_code`는 필수입니다. 선택 수량·좌석 비율은 `None`일 수 있습니다.
95
+ - 닫힌 클라이언트와 잘못된 도메인 입력은 `KorailProtocolError`로 거절합니다.
96
+ `cancel_unpaid_hold`는 기본으로 확인과 취소를 순서대로 요청합니다.
97
+
98
+ ### 검증 범위
99
+
100
+ 오프라인 검사는 운영 서버의 수용을 보장하지 않습니다. 보호된 리터럴과 미관측 응답은 검증 못 함입니다.
101
+ 셀프 체크인 변경·전달 승차권 회수·N카드의 실서버 검증 상태를 새로 확인하지 않습니다.
102
+ 기록용 `_*_unsupported.py` 세 파일은 유지하며 보호된 값을 추측해 기능을 추가하지 않습니다.
103
+ 버전 변경·태그 생성·배포는 하지 않습니다.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,15 @@
1
+ global-exclude *
2
+ include pyproject.toml MANIFEST.in LICENSE README.md CHANGELOG.md
3
+ recursive-include src/korail_mobile_api *.py
4
+ include src/korail_mobile_api/py.typed
5
+ recursive-include checks *.py *.md
6
+ recursive-include tests *.py
7
+ prune analysis
8
+ prune .git
9
+ prune .github
10
+ prune build
11
+ prune dist
12
+ global-exclude *.apk *.apks *.aab *.dex *.so *.dll *.dylib
13
+ global-exclude *.pem *.key *.p12 *.pfx *.jks *.keystore
14
+ global-exclude .env .env.* *.env .pypirc *credentials* *credential* *secrets*
15
+ global-exclude *.pyc *.pyo .DS_Store
@@ -0,0 +1,276 @@
1
+ Metadata-Version: 2.4
2
+ Name: korail-mobile-api
3
+ Version: 2.0.1
4
+ Summary: Unofficial synchronous Python client for the KORAIL mobile API
5
+ Author: yakisoba0728
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/yakisoba0728/korail-mobile-api
8
+ Project-URL: Documentation, https://yaki.kr/korail-mobile-api/
9
+ Project-URL: Repository, https://github.com/yakisoba0728/korail-mobile-api
10
+ Project-URL: Issues, https://github.com/yakisoba0728/korail-mobile-api/issues
11
+ Project-URL: Changelog, https://github.com/yakisoba0728/korail-mobile-api/blob/main/CHANGELOG.md
12
+ Keywords: korail,ktx,railway,train,reservation,api,client
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: httpx>=0.24.1
28
+ Requires-Dist: cryptography>=42.0.8
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=8.3; extra == "dev"
31
+ Requires-Dist: build>=1.2.2; extra == "dev"
32
+ Requires-Dist: twine>=6.1; extra == "dev"
33
+ Requires-Dist: ruff>=0.11; extra == "dev"
34
+ Requires-Dist: mypy>=1.15; extra == "dev"
35
+ Requires-Dist: pyright>=1.1.400; extra == "dev"
36
+ Requires-Dist: setuptools>=78.1.1; extra == "dev"
37
+ Requires-Dist: packaging>=24.2; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ > [!IMPORTANT]
41
+ > ## 🚆 The Journey Begins Again
42
+ >
43
+ > ### **여기서, 여정이 다시 시작됩니다.**
44
+ >
45
+ > 2026년 9월 1일, KORAIL과 SR이 통합되면서 SRT 열차는 KTX로 합쳐졌고, 코레일톡도 코레일+로 바뀌었습니다.
46
+ > 두 갈래로 이어져 오던 서비스가 하나의 선로 위에서 만난 것처럼,
47
+ > **[`srt-mobile-api`](https://github.com/yakisoba0728/srt-mobile-api)의 개발과 기록도
48
+ > 이제 `korail-mobile-api`로 이어집니다.**
49
+ >
50
+ > `srt-mobile-api`는 여기서 멈췄지만, 그 안에서 확인한 수많은 요청과 응답,
51
+ > 시행착오와 검증의 기록까지 사라지는 것은 아닙니다.
52
+ > 그 경험은 이 프로젝트의 다음 장을 이루는 기반으로 남습니다.
53
+ >
54
+ > **우리는 SRT를 기억할 것입니다.**
55
+ > 하나의 프로젝트는 종착역에 도착했지만, 그 여정은 이곳에서 다시 출발합니다.
56
+ >
57
+ > **One journey ended. Another begins here.**
58
+ >
59
+ > → [`srt-mobile-api` — Final Stop](https://github.com/yakisoba0728/srt-mobile-api)
60
+
61
+ <p align="center">
62
+ <picture>
63
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/yakisoba0728/korail-mobile-api/main/docs/assets/banner-dark.svg">
64
+ <img src="https://raw.githubusercontent.com/yakisoba0728/korail-mobile-api/main/docs/assets/banner-light.svg" alt="korail-mobile-api" width="100%">
65
+ </picture>
66
+ </p>
67
+
68
+ <p align="center">
69
+ <a href="https://github.com/yakisoba0728/korail-mobile-api/actions/workflows/ci.yml"><img src="https://github.com/yakisoba0728/korail-mobile-api/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
70
+ <a href="https://pypi.org/project/korail-mobile-api/"><img src="https://img.shields.io/pypi/v/korail-mobile-api" alt="PyPI"></a>
71
+ <img src="https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-3776AB?logo=python&amp;logoColor=white" alt="Python 3.11 | 3.12 | 3.13 | 3.14">
72
+ <img src="https://img.shields.io/badge/typing-mypy%20strict-2A6DB2" alt="mypy strict">
73
+ <img src="https://img.shields.io/badge/%EC%BD%94%EB%A0%88%EC%9D%BC%2B-7.0.6%20%EA%B8%B0%EC%A4%80-0b7a75" alt="코레일+ 7.0.6 기준">
74
+ <a href="https://github.com/yakisoba0728/korail-mobile-api/blob/main/LICENSE"><img src="https://img.shields.io/github/license/yakisoba0728/korail-mobile-api" alt="License"></a>
75
+ </p>
76
+
77
+ <p align="center">
78
+ <a href="https://yaki.kr/korail-mobile-api/">문서</a> ·
79
+ <a href="#설치">설치</a> ·
80
+ <a href="#빠르게-써보기">빠르게 써보기</a> ·
81
+ <a href="#예약결제환불">예약·결제·환불</a> ·
82
+ <a href="#지원-범위">지원 범위</a> ·
83
+ <a href="#동작-방식">동작 방식</a> ·
84
+ <a href="#법적-고지">법적 고지</a>
85
+ </p>
86
+
87
+ 코레일+ 안드로이드 앱이 서버에 보내는 요청을 그대로 따라 하는 비공식 Python 클라이언트입니다.
88
+ 2026년 9월 KORAIL과 SR이 통합되면서 SRT는 KTX로 합쳐졌고, 코레일톡도 코레일+로 이름이 바뀌었습니다.
89
+
90
+ KORAIL과는 관계없는 개인 프로젝트입니다. 공식 API가 아니라서 KORAIL이 서버나 앱을 바꾸면 언제든 깨질 수 있습니다.
91
+ 쓰기 전에 [법적 고지](#법적-고지)는 꼭 읽어 주세요.
92
+
93
+ - **타입이 붙은 응답** — 응답은 전부 dataclass로 돌려주고, 서버가 준 원본은 `.raw`에 남겨 둡니다.
94
+ - **실수하기 어렵게** — 결제 금액은 홀드의 `received_amount`를 그대로 쓰고, 0원·예약대기 홀드를 카드로 결제하려는 건 아닌지, 환불 전에 수수료를 조회했는지 요청 전에 확인합니다.
95
+ - **네트워크 없이 도는 테스트 2,100여 개** — CI에서 Python 3.11~3.14로 `pytest`, `mypy --strict`, `pyright`, `ruff`를 돌립니다.
96
+
97
+ ## 설치
98
+
99
+ Python 3.11 이상이 필요합니다.
100
+
101
+ ```sh
102
+ pip install korail-mobile-api
103
+ ```
104
+
105
+ 아직 릴리스되지 않은 최신 코드는 GitHub에서 바로 설치할 수 있습니다.
106
+
107
+ ```sh
108
+ pip install "git+https://github.com/yakisoba0728/korail-mobile-api"
109
+ ```
110
+
111
+ 의존성은 `httpx`와 `cryptography` 두 개뿐입니다.
112
+
113
+ ## 빠르게 써보기
114
+
115
+ 열차 조회는 로그인 없이 됩니다.
116
+
117
+ ```python
118
+ from korail_mobile_api import KorailClient, TrainSearchQuery
119
+
120
+ client = KorailClient()
121
+ try:
122
+ query = TrainSearchQuery(
123
+ departure_station_code="서울",
124
+ arrival_station_code="부산",
125
+ departure_date="20261002",
126
+ departure_time="090000",
127
+ )
128
+ result = client.search_trains(query)
129
+ for t in result.trains:
130
+ print(t.train_class_name, t.train_no, t.departure_time, t.arrival_time)
131
+ finally:
132
+ client.close()
133
+ ```
134
+
135
+ <p align="center">
136
+ <img src="https://raw.githubusercontent.com/yakisoba0728/korail-mobile-api/main/docs/assets/demo.svg" alt="열차 조회 실행 예시" width="100%">
137
+ </p>
138
+
139
+ 역은 이름이나 역 코드 어느 쪽으로 넣어도 됩니다. 날짜는 `YYYYMMDD`, 시각은 `HHMMSS`입니다.
140
+ 결과는 한 페이지씩 옵니다. `result.next_page()`가 `None`이 아니면 `client.search_trains(query, continuation=result.next_page())`로 다음 페이지를 받습니다.
141
+ `None`이면 `result.next_query_from_last_departure(query)`로 마지막 열차의 출발일·출발 시각부터 조회할 조건을 만들어 다시 조회할 수 있습니다. 마지막 열차가 다시 포함될 수 있으니 열차 번호로 중복을 거르세요.
142
+
143
+ 로그인하면 내 승차권과 예약 내역도 볼 수 있습니다.
144
+
145
+ ```python
146
+ from getpass import getpass
147
+
148
+ from korail_mobile_api import KorailClient
149
+
150
+ client = KorailClient()
151
+ try:
152
+ client.login(input("회원번호·전화번호·이메일: "), getpass("비밀번호: "))
153
+ tickets = client.get_ticket_list()
154
+ print(sum(len(r.tickets) for r in tickets.reservations), "장")
155
+ finally:
156
+ try:
157
+ client.logout()
158
+ finally:
159
+ client.close()
160
+ ```
161
+
162
+ 로그인 ID는 하이픈 없는 회원번호·전화번호나 이메일입니다. 로그인에 실패하면 계정 잠금 횟수에 들어갈 수 있으니 조심하세요.
163
+
164
+ ## 예약·결제·환불
165
+
166
+ **이 메서드들은 부르는 순간 실제로 처리됩니다.** 확인 창이나 미리보기 같은 건 없습니다.
167
+ 예약하면 좌석이 잡히고, 결제하면 카드가 실제로 청구되고, 환불에는 수수료가 붙을 수 있습니다.
168
+
169
+ | 하려는 것 | 메서드 | 알아둘 점 |
170
+ |---|---|---|
171
+ | 좌석 잡기 (결제 전) | `reserve`, `reserve_transfer`, `reserve_merge`, `reserve_limousine` | 승객 구성은 조회할 때와 같게 넣습니다. |
172
+ | 결제 전 취소 | `cancel_unpaid_hold` | 결제한 표에는 쓰지 않습니다. |
173
+ | 카드 결제 | `pay_with_card` | 카드 거절은 예외가 아니라 FAIL 응답으로 돌아옵니다. |
174
+ | 환불 | `get_refund_commission` → `refund(..., commission=...)` | 승차권 한 장씩이고, 수수료 조회가 먼저입니다. `commission`이 수수료 조회의 성공 응답이 아니면(`None` 포함) 요청 전에 거절합니다. |
175
+ | 할인 재계산 | `PriceRecalculationRequest.for_hold` → `recalculate_price` | 결제는 재계산된 홀드로 합니다. |
176
+
177
+ 변경 요청은 자동으로 다시 보내지 않습니다. 응답을 못 읽어서 예외가 나도 서버에서는 이미 처리됐을 수 있습니다.
178
+ 그럴 땐 다시 보내지 말고 예외의 `.raw`를 보고, 예약은 `get_reservation_history()`, 결제·환불은 `get_ticket_list()`로 먼저 확인하세요.
179
+
180
+ ## 지원 범위
181
+
182
+ 공개 메서드는 84개이고, 2026년 9월 24~26일에 실서버로 하나씩 확인했습니다.
183
+
184
+ | 영역 | 메서드 | 실서버 확인 | 예 |
185
+ |---|---:|---:|---|
186
+ | 로그인·세션 | 4 | 2 | `login`, `logout` (나머지 둘은 네트워크를 쓰지 않음) |
187
+ | 공통 정보 | 9 | 9 | 역 목록, 운행 달력, 공지 |
188
+ | 열차 조회·좌석 | 12 | 11 | `search_trains`, 환승 조회, 호차·좌석 배치, 운임 |
189
+ | 공항버스·부가서비스 | 6 | 6 | 공항버스 스케줄·좌석, 부가서비스 메뉴 |
190
+ | 정기권·패스 | 6 | 6 | 패스 사용 가능일, 정기권 조건 |
191
+ | 내 승차권·계정 | 28 | 21 | 승차권 목록, 예약 내역, 영수증, 마일리지, 지연확인증 |
192
+ | 예약·결제·환불 | 19 | 11 | `reserve`, `pay_with_card`, `refund` |
193
+
194
+ 확인 못 한 것 중 4개는 요청은 서버까지 갔지만 이 계정에 해당 자료나 자격이 없어서 실패 응답만 봤습니다.
195
+ 나머지 12개는 필요한 카드나 승차권이 없어서 성공 응답을 보지 못했습니다. 이 중 3개는 요청을 보내 실패 응답만 받았습니다. 코드는 앱과 똑같이 짰습니다.
196
+
197
+ - N카드: 구매, 기간 연장, N카드로 예약, 사용 내역, 이용 가능 열차, 2인 승차권 수령자 조회
198
+ - 셀프 체크인: 좌석 확인, 등록, 취소
199
+ - 역에서 산 승차권 환불: 확인, 실행
200
+ - 다른 회원에게 전달한 승차권 회수
201
+
202
+ 간편 로그인(카카오·네이버 등), 여행상품 검색·예약·결제, 부가서비스 구매·결제·환불은 지원하지 않습니다.
203
+ 앱에서 필요한 값이 암호화돼 있거나 외부 SDK를 거쳐야 해서입니다.
204
+ 정기권·패스 구매, 다른 회원에게 승차권 전달, 승차권 변경도 지원하지 않습니다. 관련 정보를 조회하는 메서드는 있지만 실행하는 메서드는 없습니다.
205
+
206
+ ## 동작 방식
207
+
208
+ <p align="center">
209
+ <picture>
210
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/yakisoba0728/korail-mobile-api/main/docs/assets/flow-dark.svg">
211
+ <img src="https://raw.githubusercontent.com/yakisoba0728/korail-mobile-api/main/docs/assets/flow-light.svg" alt="요청 흐름" width="100%">
212
+ </picture>
213
+ </p>
214
+
215
+ - 폼은 앱의 요청 DTO에 선언된 순서대로 만듭니다. 앱이 그 순서로 보내기 때문입니다.
216
+ - 열차 조회, 일부 예약(`reserve`, `reserve_transfer`, `reserve_with_discount_card`), 카드 결제, 예약 내역 조회 전에는 앱처럼 NetFunnel 대기열을 거칩니다. 기본으로 켜져 있습니다.
217
+ - 로그인 비밀번호는 앱처럼 AES로 암호화해서 보냅니다.
218
+ - 응답을 못 읽으면 받은 원문 전체를 예외의 `.raw`에 담아 던집니다.
219
+
220
+ 더 자세한 규칙과 앱과 다르게 처리한 부분은 [checks/BEHAVIOR.md](https://github.com/yakisoba0728/korail-mobile-api/blob/main/checks/BEHAVIOR.md)에 정리해 뒀습니다.
221
+
222
+ ## 자주 묻는 질문
223
+
224
+ **SRT는요?**
225
+ SRT는 2026년 9월 통합 때 KTX로 합쳐져서 이제 따로 없습니다. 예매는 코레일+ 앱 하나로 하고, 이 라이브러리도 그 앱의 요청을 씁니다.
226
+ SRT 앱용으로 만들었던 [srt-mobile-api](https://github.com/yakisoba0728/srt-mobile-api)는 개발을 멈추고 이 저장소로 이어졌습니다.
227
+
228
+ **대기열을 끄면 빨라지나요?**
229
+ `KorailConfig(netfunnel_enabled=False)`로 끌 수는 있습니다. 하지만 앱과 다르게 동작하게 되고 KORAIL의 혼잡 제어를 건너뛰는 셈이라 권하지 않습니다.
230
+
231
+ **비밀번호나 카드 번호는 어디에 저장되나요?**
232
+ 어디에도 저장하지 않습니다. KORAIL 서버로만 보내고 파일로 쓰지 않습니다.
233
+ 다만 응답 모델과 예외의 `.raw`에는 개인정보가 그대로 들어 있으니 로그에 그대로 찍지 않도록 조심하세요.
234
+
235
+ ## 문서와 링크
236
+
237
+ - [문서 사이트](https://yaki.kr/korail-mobile-api/) — 시작하기, 가이드, 메서드 84개 전체의 API 레퍼런스
238
+ - [동작 규칙 (checks/BEHAVIOR.md)](https://github.com/yakisoba0728/korail-mobile-api/blob/main/checks/BEHAVIOR.md) — 요청을 만드는 규칙, 응답을 읽는 규칙, 앱과 다르게 한 부분
239
+ - [변경 이력 (CHANGELOG.md)](https://github.com/yakisoba0728/korail-mobile-api/blob/main/CHANGELOG.md)
240
+ - [오프라인 검사 기준 (checks/ACCEPTANCE.md)](https://github.com/yakisoba0728/korail-mobile-api/blob/main/checks/ACCEPTANCE.md)
241
+ - 한국철도공사 공식 홈페이지 — <https://www.korail.com>
242
+ - 코레일+ 앱 — [Google Play](https://play.google.com/store/apps/details?id=com.korail.talk) · [App Store](https://apps.apple.com/kr/app/id1000558562)
243
+ - 이전 SRT 클라이언트 — [srt-mobile-api](https://github.com/yakisoba0728/srt-mobile-api)
244
+
245
+ ## 개발
246
+
247
+ ```sh
248
+ git clone https://github.com/yakisoba0728/korail-mobile-api
249
+ cd korail-mobile-api
250
+ pip install -e ".[dev]"
251
+
252
+ pytest
253
+ ruff check src checks tests && ruff format --check src checks tests
254
+ mypy && pyright
255
+ python checks/contract_api.py && python checks/netfunnel_offline.py
256
+ ```
257
+
258
+ 테스트는 전부 가짜 응답으로 돌고 소켓을 막아 둬서 실수로 실서버에 요청이 나가지 않습니다.
259
+ 버그나 앱 업데이트로 달라진 부분을 찾으면 이슈로 알려 주세요.
260
+
261
+ ## 법적 고지
262
+
263
+ - 이 프로젝트는 한국철도공사(KORAIL)와 관계없는 개인의 비공식 프로젝트이며, 후원·승인·지원을 받지 않았습니다. 통합 전의 (주)에스알(SR)과도 관계없습니다.
264
+ - KORAIL, 코레일, 코레일+, 코레일톡, KTX, SRT 등의 이름과 상표는 각 권리자의 것입니다. 이 저장소는 무엇과 호환되는지 설명하려고 이름만 씁니다. 저장소의 이미지는 직접 만들었고 공식 로고는 쓰지 않았습니다.
265
+ - 저장소에는 앱 설치 파일(APK)이나 디컴파일한 앱 소스를 넣지 않았습니다. 라이브러리는 앱과 호환되도록 요청 형식만 재현합니다.
266
+ - 이 라이브러리로 하는 예약·결제·환불은 전부 실제 거래입니다. 그 결과와 비용은 사용자 책임입니다.
267
+ - KORAIL 서비스를 쓸 때는 KORAIL의 이용약관과 여객운송약관을 따라야 합니다. 자동화된 방식으로 쓰는 것이 약관에 맞는지는 사용자가 직접 확인해야 합니다.
268
+ - KORAIL은 매크로 탐지 시스템을 운영하고 있습니다. 자동 프로그램 사용이 의심되면 로그인·조회 단계부터 접속을 막고, 대량 구매·취소에 쓰인 카드는 1년 동안 승차권 결제를 제한한다고 밝혔습니다([2025년 10월 보도](https://www.paxetv.com/news/articleView.html?idxno=248146)).
269
+ - 승차권을 상습적으로 또는 영업으로 산 값보다 비싸게 되팔거나 이를 알선하는 행위는 [철도사업법 제10조의2](https://www.law.go.kr/%EB%B2%95%EB%A0%B9/%EC%B2%A0%EB%8F%84%EC%82%AC%EC%97%85%EB%B2%95)로 금지돼 있고, 최대 1천만 원의 과태료가 부과될 수 있습니다. 이 라이브러리를 암표, 좌석 선점, 대량 예매에 쓰지 마세요.
270
+ - 계정과 카드 정보 관리는 사용자 몫입니다. 라이브러리는 로그나 `.raw`의 개인정보를 가리지 않습니다.
271
+ - 이 소프트웨어는 Apache License 2.0에 따라 "있는 그대로" 제공되며 어떤 보증도 하지 않습니다. 사용하다 생긴 손해에 대해 저작자는 책임지지 않습니다.
272
+ - 어떤 용도로 쓰든 막지는 않습니다. 다만 되도록 개인 용도로만 쓰고, 상업적이거나 불법적인 용도로는 쓰지 말아 주세요. 라이선스 조건이 아니라 부탁입니다.
273
+
274
+ ## 라이선스
275
+
276
+ [Apache License 2.0](https://github.com/yakisoba0728/korail-mobile-api/blob/main/LICENSE)