WestJR
JR西日本列車走行位置 非公式API Async-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 async-westjr
Usage
import async_westjr
jr = async_westjr.WestJR()
# あらかじめ area や line をセットする
jr = async_westjr.WestJR(line="kobesanyo", area="kinki")
Example
列車走行位置取得
async def get_trains():
data = await jr.get_trains()
print(data)
await get_trains()
# TrainPos(update='2023-03-21T16:54:54.612Z', trains=[TrainsItem(no='502C', ...
メンテナンス予定取得
async def get_maintenance():
data = await jr.get_maintenance()
print(data)
await get_maintenance()
# 平常時:
# AreaMaintenance(status=0, notification=Notification(groupId=0, text='', duration=''), ...
# 異常時:
# AreaMaintenance(status=1, notification=Notification(groupId=2023012802, text='1月24日から1月31日を, ...
路線一覧取得
async def get_lines():
data = await jr.get_lines()
print(data)
await get_lines()
# AreaMaster(lines={'ako': Line(name='赤穂線', range='相生〜播州赤穂', relatelines=None, st='...
駅一覧取得
async def get_stations():
data = await jr.get_stations()
print(data)
await get_stations()
# Stations(stations=[StationsItem(info=Info(name='新大阪', code='0415', stopTrains=[1, 2, 5], typeNotice=None, ...
運行情報取得
async def get_traffic_info():
data = await jr.get_traffic_info()
print(data)
await 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']
列車環境取得
async def get_train_monitor_info():
congestion = (await jr.get_train_monitor_info()).trains["3489M"][0].cars[0].congestion
print(congestion)
# 26(%)
temp = (await jr.get_train_monitor_info()).trains["3489M"][0].cars[0].temp
print(temp)
# 23(°C)
駅に停車する種別を id から名称に変換する
async def get_train_monitor_info():
station = (await jr.get_stations(line="kyoto")).stations[0]
print(station.info.name)
# 山科
print(jr.convert_stopTrains(station.info.stopTrains))
# ['新快速', '快速', '特急']
列車走行位置の場所を前駅と次駅の名前に変換する
async def get_convert_pos():
train = (await jr.get_trains(line="kobesanyo")).trains
tr = train[0]
prev, next = jr.convert_pos(train=tr)
print(prev)
# 塚本
Contribution
- PRを出してください
Metadata
Release files for async-westjr 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| async-westjr-0.4.tar.gz | 16.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_westjr-0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.1 kB
Release files / async-westjr-0.4.tar.gz
| Download URL | async-westjr-0.4.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22cea21cf57dd8940915c84f99b6e717d5fc8c4bd3738224527d88036dcee5c1
|
|
BLAKE2b-256 checksum How to use checksums |
32df86b37ad11d43df82d1b20ac0ebbcf41cfb7ce82056665cf1128895ee36b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|
Release files / async_westjr-0.4-py3-none-any.whl
| Download URL | async_westjr-0.4-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24e002730df35abe94052125c5d6b83471cc3dbbd95ba9c404a0104556b968a3
|
|
BLAKE2b-256 checksum How to use checksums |
6b12954ce6cbff81d81d1f9f5d0717e677cac83b6cea87c4fc03bdef7680f148
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|