-
Notifications
You must be signed in to change notification settings - Fork 3
Documentation
The get_departures() method takes between 1 and 4 positional arguments. These are:
-
tiploc(Timing location point) (a string) - like "KNGX" -
filter(a string) - like "STEVNGE" -
date(a string) - like "2024/11/16" (Support for specific times will be added soon) -
time(a string) - like "1250" (12:50) -
rows(an integer) - like 15
The filter, time, date and rows arguments are all optional. If left blank, a filter will not be applied, the date and time will be defaulted to the current date and time (UTC) and the rows will default to the number of rows returned by the API. Rows cannot be specified if you're using complex mode.
The time you pass into the function should be an integer of the 24-hour time you need. For example, if departures at 16:55 are needed, the time will be 1655.
The get_departures() method returns the departures for the station you specified. The amount of data and how it is formatted returned will depend on the complexity you specified upon initialising the package.
Here is one request you could provide:
get_departures(tiploc = "KNGX", filter = "STEVNGE", date = "2024/11/16", time = "1250", rows = 20)
This request will return up to 20 rows of departures for London King's Cross (KNGX) on 16/11/2024 around 12:50, provided they call at Stevenage (STEVNGE).
Tip
In the tiploc and filter fields, station CRS (Computer Reservation System) codes can be provided instead of a TIPLOC (Timing Point Location).
However, it is recommended that you use the TIPLOC instead of the CRS
A list of TIPLOC and CRS codes can be found here. This site is not managed by realtime-trains-py.
Similar to get_departures(), the get_arrivals() method takes between 1 and 4 positional arguments. These are:
-
tiploc(Timing location point) (a string) - like "KNGX" -
filter(a string) - like "STEVNGE" -
date(a string) - like "2024/11/16" (Support for specific times will be added soon) -
time(a string) - like "1250" (12:50) -
rows(an integer) - like 15
The filter, time, date and rows arguments are all optional. If left blank, a filter will not be applied, the date and time will be defaulted to the current date and time (UTC) and the rows will default to the number of rows returned by the API. Rows cannot be specified if you're using complex mode.
The time you pass into the function should be an integer of the 24-hour time you need. For example, if departures at 16:55 are needed, the time will be 1655.
The get_arrivals() method returns the arrivals for the station you specified. The amount of data and how it is formatted returned will depend on the complexity you specified upon initialising the package.
Here is one request you could provide:
get_arrivals(tiploc = "KNGX", filter = "STEVNGE", date = "2024/11/16", time = "1250", rows = 20)
This request will return up to 20 rows of arrivals for London King's Cross (KNGX) on 16/11/2024 around 12:50, provided they call at Stevenage (STEVNGE).
Tip
In the tiploc and filter fields, station CRS (Computer Reservation System) codes can be provided instead of a TIPLOC (Timing Point Location).
However, it is recommended that you use the TIPLOC instead of the CRS
A list of TIPLOC and CRS codes can be found here. This site is not managed by realtime-trains-py.
The get_service() method takes 1 or 2 positional arguments. These are:
-
service_uid(a string) - like "G54072" -
date(a string) - like "2024/11/16" (Support for specific times will be added soon)
The date argument is optional. It will be defaulted to the current date (UTC) if left blank.
The get_service() method returns the informtion for the specified. The amount of data returned will depend on the complexity you specified upon initialising the package.
Here is one request you could provide:
get_service(service_uid = "G54072", date = "2024/11/16")
This request will return the service information for G54072 on 16/11/2024.
Service UID not recognised. Status code: 404This error means that the Service UID you entered doesn't match any service on the server. The Service UID should be a 6-character string. It should start with one (1) letter (not case-sensitive) followed by five (5) integers.. For example G54072 - which is the Service UID for 9J35. The package will return the error shown above if you provide the headcode (9J35 in this case). Due to API limitations, Service UIDs must be provided instead.
Access blocked: check your credentials. Status code: 401 | 403This error means that the credentials you provided when you initialised the package were unable to be verified by the API server. If your credentials are correct and you are unable to access the API, you should contact the API support via the api portal. This error is unlikely to be a problem with realtime-trains-py. If you have recently registered it may take a while for your details to be verified before you can access the API. If this problem persists, visit the api portal for support. You can also report an issue with realtime-trains-py on GitHub so that we can check our systems.
Date provided did not meet requirements or fall into the valid date range.This error means that a date you provided was not accepted by the system. Your date should be provided in the form dd/mm/yyyy, and not be more than eight (8) days before the current date or more than 80 days after the current date. For example, on the 9th January 2025 (09/01/2025), the earliest date that can be requested is the 2nd January 2025 (02/01/2025) and the latest date is the 30th March 2025 (30/03/2025)
Tip
Turn on complex mode to bypass this error. Complex mode allows you to access more data.
Warning
Dates requested that are more than two (2) weeks after the current date are unlikely to be representative or accurate of the timetable on that day.
Missing details. Both username and password must be provided. Only one field was provided.This error means that you didn't pass in a username and a password when you initialised the package. Make sure you read the setup guide before running your code. If this problem persists and you have correctly followed the setup guide, report an issue with realtime-trains-py on GitHub so that we can check our systems.
Complexity not recognised. Select a valid type.This error means that you didn't select a valid complexity type when you initialised the package. Make sure you read the setup guide before running your code. If this problem persists and you have correctly followed the setup guide, report an issue with realtime-trains-py on GitHub so that we can check our systems.
All of our data is kindly provided by Realtime Trains.