WestJR
JR西日本列車走行位置 非公式API Pythonライブラリ
- 列車走行位置取得 (
/api/v3/{LINE}.json) - メンテナンス予定取得 (
/api/v3/area_{AREA}_maintenance.json) - 路線名取得 (
/api/v3/area_{AREA}_master.json) - 駅一覧取得 (
/api/v3/{LINE}_st.json) - 運行情報取得 (
/api/v3/area_{AREA}_trafficinfo.json) - 列車環境取得 (
/api/v3/trainmonitorinfo.json) - 列車走行位置駅名,列車停車種別の変換
Notice
- 動作を完全には確認していません.
Installation
pip install WestJR
Usage
Wiki に情報があります.
import westjr
jr = westjr.WestJR()
# あらかじめ area や line をセットする
jr = westjr.WestJR(line="kobesanyo", area="kinki")
Example
列車走行位置取得
print(jr.get_trains())
# TrainPos(update='2023-03-21T16:54:54.612Z', trains=[TrainsItem(no='502C', ...
メンテナンス予定取得
print(jr.get_maintenance())
# 平常時:
# AreaMaintenance(status=0, notification=Notification(groupId=0, text='', duration=''), ...
# 異常時:
# AreaMaintenance(status=1, notification=Notification(groupId=2023012802, text='1月24日から1月31日を, ...
路線一覧取得
print(jr.get_lines())
# AreaMaster(lines={'ako': Line(name='赤穂線', range='相生〜播州赤穂', relatelines=None, st='...
駅一覧取得
print(jr.get_stations())
# Stations(stations=[StationsItem(info=Info(name='新大阪', code='0415', stopTrains=[1, 2, 5], typeNotice=None, ...
運行情報取得
print(jr.get_traffic_info())
# 平常時:
# TrainInfo(lines={}, express={})
# 異常時:
# TrainInfo(lines={'bantan': Info_LineItem(...)}, express={'bantan': Info_ExpressItem(...)})
エリア名一覧表示
print(jr.areas)
# ['hokuriku', 'kinki', 'okayama', 'hiroshima', 'sanin']
路線名一覧表示
print(jr.lines)
# ['hokuriku', 'kobesanyo', 'hokurikubiwako', 'kyoto', 'ako', 'kosei', 'kusatsu', 'nara', 'sagano', 'sanin1', 'sanin2', 'osakahigashi', 'takarazuka']
列車環境取得
print(jr.get_train_monitor_info().trains["3489M"][0].cars[0].congestion)
# 26(%)
print(jr.get_train_monitor_info().trains["3489M"][0].cars[0].temp)
# 23(°C)
駅に停車する種別を id から名称に変換する
station = jr.get_stations(line="kyoto").stations[0]
print(station.info.name)
# 山科
print(jr.convert_stopTrains(station.info.stopTrains))
# ['新快速', '快速', '特急']
列車走行位置の場所を前駅と次駅の名前に変換する
train = jr.get_trains(line="kobesanyo").trains
tr = train[0]
prev, next = jr.convert_pos(train=tr)
print(prev)
# 塚本
Contribution
- develop ブランチにお願いします
- インストールしていなければ poetry をインストールしてください
- 初回は
poetry install && poetry run pre-commit installを実行することでpoetryとpre-commitのセットアップが行えます poetry shellを実行すると仮想環境で開発することができます
Metadata
Release files for WestJR 0.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| westjr-0.4.3.tar.gz | 16.7 kB | Without provenance | Details for westjr-0.4.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| westjr-0.4.3-py3-none-any.whl | Python 3 | none | any | Details for westjr-0.4.3-py3-none-any.whl |
Total release size: 33.9 kB
Release files / westjr-0.4.3.tar.gz
| Download URL | westjr-0.4.3.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ecd6ad898b4d8903d2a2e0f510ec1c77f42118cc8deca8bcc3406108036d0af
|
|
BLAKE2b-256 checksum How to use checksums |
c60a73140fb2078bff0d90d9f6b918f284a53dd88988e845b24a95eb66a44bb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.11
|
Release files / westjr-0.4.3-py3-none-any.whl
| Download URL | westjr-0.4.3-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03de7e9862bc2404faa23d84380fccd4d0e31c37c7d9398ba16eb05344fa28c3
|
|
BLAKE2b-256 checksum How to use checksums |
10e79b83fe94156ee2f777d27076149a7e4137fdd5e9f6dcfd39d873d6142c62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.11
|
Security for WestJR 0.4.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.