This is a python script that uses Transport For Wales' API to get train arrival and departure times.
python3 trainTimes.py <origin> <destination> <time> <date>
trainTimes.py also serves as an example as to how the library is used.
| Attribute | Type |
|---|---|
origin |
str |
destination |
str |
time |
str |
date |
str |
NOTE: both time and date are subject to change in the future, mostly date, which
is likely to change to datetime.
>>> import station
>>> station = station.Departures("GBCDF", "GBQQM", "2023-10-10", "12:00")
>>> station
<station.Departures object at 0x7f296cd40b50>Station returns a station.Departures object. station.legs returns the departures
from GBCDF to GBQQM.
>>> station.legs
[{'sequence': '0', 'travelSegmentID': 'LS_1_0_TS_0', 'type': 'TRAIN', 'originTravelPoint':
{'origin': 'GBCDF', 'type': 'STATION'}, 'destinationTravelPoint':
{'origin': 'GBQQM', 'type': 'STATION'}, 'departureDateTime': '2023-10-10T11:53:00',
'arrivalDateTime': '2023-10-10T15:15:00', ...
>>>Additional arguments can also be supplied for more search terms
| Attribute | Type |
|---|---|
child |
int |
adult |
int |
earlierSearch |
bool |
ticketType |
str = "single" OR "return" |
>>> import station
>>> args = {"child": 1, "adult": 2, "earlierSearch": False, "ticketType": "single"}
>>> station = station.Departures("GBCDF", "GBQQM", "2024-02-01", "10:00", args)
>>> station.legs
[{'sequence': '0', 'travelSegmentID': 'LS_1_0_TS_0', 'type': 'TRAIN', 'originTravelPoint': {'origin': 'GBCDF', 'type': 'STATION'}, ...At the time of writing this (almost two years ago) the Transport For Wales app was VERY slow, as such, this was a lot faster if all I was doing was remembering when my train was supposed to depart.