Skip to main content

Handling of train operation information of JR West, a railroad company in Japan

Project description

WestJR

Python Versions PyPI pre-commit.ci status GitHubActions

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 を実行することで poetrypre-commit のセットアップが行えます
  • poetry shell を実行すると仮想環境で開発することができます

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

westjr-0.4.3.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

westjr-0.4.3-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file westjr-0.4.3.tar.gz.

File metadata

  • Download URL: westjr-0.4.3.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for westjr-0.4.3.tar.gz
Algorithm Hash digest
SHA256 5ecd6ad898b4d8903d2a2e0f510ec1c77f42118cc8deca8bcc3406108036d0af
MD5 b6198cada7f94517e9071b10f97a4da1
BLAKE2b-256 c60a73140fb2078bff0d90d9f6b918f284a53dd88988e845b24a95eb66a44bb7

See more details on using hashes here.

File details

Details for the file westjr-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: westjr-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for westjr-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 03de7e9862bc2404faa23d84380fccd4d0e31c37c7d9398ba16eb05344fa28c3
MD5 ba6199e93b832839746b73b965bd2ee3
BLAKE2b-256 10e79b83fe94156ee2f777d27076149a7e4137fdd5e9f6dcfd39d873d6142c62

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page