Skip to content

Python script that prints the train arrival and departure times from the Transport For Wales API.

License

Notifications You must be signed in to change notification settings

cristobers/TrainTimeFinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Train Time Finder For TFW Services

What is this?

This is a python script that uses Transport For Wales' API to get train arrival and departure times.

How do I use this?

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.

Examples

>>> 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'}, ...

Why did you make this?

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.

About

Python script that prints the train arrival and departure times from the Transport For Wales API.

Topics

Resources

License

Stars

Watchers

Forks

Languages