Handling of train operation information of JR West, a railroad company in Japan
Project description
Async-WestJR
JR西日本列車走行位置 非公式API Pythonライブラリ (async版)
- 列車走行位置取得 (/api/v3/LINE.json)
- 路線名取得 (/api/v3/area_AREA_master.json)
- 駅一覧取得 (/api/v3/LINE_st.json)
- 運行情報取得 (/api/v3/area_AREA_trafficinfo.json)
- 列車走行位置駅名,列車停車種別の変換
Notice
- 動作を完全には確認していません.
Installation
$ python3 -m pip install git+https://github.com/midorichaan/async-westjr.git
$ python3 -m pip install git+ssh://git@github.com/midorichaan/async-westjr
Usage
import async_westjr
jr = async_westjr.WestJR()
# あらかじめ area や line をセットする
jr = async_westjr.WestJR(line="kobesanyo", area="kinki")
Example
列車走行位置取得
coro = await jr.get_trains()
print(coro)
# {'update': '2021-03-31T08:14:34.313Z', 'trains': [{'no': '798T', 'pos': '0414_0415', ...```
駅一覧取得
coro = await jr.get_stations()
print(coro)
# {'stations': [{'info': {'name': '新大阪', 'code': '0415', 'stopTrains': [1, 2, 5], 'typeNotice': None, ...
路線一覧取得
coro = await jr.get_lines()
print(coro)
# {'lines': {'ako': {'name': '赤穂線', 'range': '相生〜播州赤穂', 'st': ...
運行情報取得
coro = await jr.get_traffic_info()
print(coro)
# {'lines': {}, 'express': {}}
エリア名一覧表示
print(jr.areas)
# ['hokuriku', 'kinki', 'okayama', 'hiroshima', 'sanin']
路線名一覧表示
print(jr.lines)
# ['hokuriku', 'kobesanyo', 'hokurikubiwako', 'kyoto', 'ako', 'kosei', 'kusatsu', 'nara', 'sagano', 'sanin1', 'sanin2', 'osakahigashi', 'takarazuka']
駅に停車する種別を id から名称に変換する
station = (await jr.get_stations(line="kyoto"))["stations"][0]
print(station["info"]["name"])
print(jr.convert_stopTrains(station["info"]["stopTrains"]))
# 山科
# ['新快速', '快速', '特急']
列車走行位置の場所を前駅と次駅の名前に変換する
train = (await jr.get_trains(line="kobesanyo"))["trains"]
tr = train[0]
prev, next = jr.convert_pos(train=tr)
print(prev)
# 塚本
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async-westjr-0.0.1.tar.gz
(12.3 kB
view hashes)
Built Distribution
Close
Hashes for async_westjr-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1136cd50b2da201ac69acaed9fff20574f28ae61f4c540b21ac59f3456fe35e9 |
|
MD5 | 324759cde8924fc7db42e2aa74d0a9a9 |
|
BLAKE2b-256 | 7f5d03f6b65b744d9d4824d9975101acecd73844a84f7d9beb105f039f6d5f95 |