WhereIsMyTrain

Remember:

  • Replace placeholders like your_irctc_user_id and your_phone_number with actual values.
  • You'll need to have the MultiFeatures package installed to run these examples.
  • These examples are asynchronous and need to be run within an async function using await.
  • Install the package using pip install -U MultiFeatures.

Usage

from MultiFeatures.IndianRailway import whereismytrain
 
wit = whereismytrain.WhereIsMyTrain()

Methods

sync_train_schedule(last_synced: int = 0, dev_mode: bool = False, data_version: str = "7.2.4", network_type: str = "WIFI", lang: str = "en")

Syncs the train schedule with the server.

Parameters:

  • last_synced (int): The timestamp of the last sync. Defaults to 0.
  • dev_mode (bool): Whether to use dev mode. Defaults to False.
  • data_version (str): The version of the data. Defaults to "7.2.4".
  • network_type (str): The type of network connection. Defaults to "WIFI".
  • lang (str): The language for the response. Defaults to "en".

Returns:

  • dict: The JSON response containing the synced train schedule.

Example:

schedule = await wit.sync_train_schedule()
print(schedule)

live_status(train_no: str, date: str, from_station: str, to_station: str, from_day: int = 1, lang: str = "en")

Gets the live status of a train.

Parameters:

  • train_no (str): The train number.
  • date (str): The date of journey in the format 'dd-mm-yyyy'.
  • from_station (str): The source station code.
  • to_station (str): The destination station code.
  • from_day (int): The day of journey. Defaults to 1.
  • lang (str): The language for the response. Defaults to "en".

Returns:

  • dict: The JSON response containing live train status information.

Raises:

  • NotAValidTrainNumber: If the provided train number is not valid.

Example:

status = await wit.live_status("12625", "10-11-2023", "NDLS", "MAS")
print(status)

live_station(station_code: str, hrs: int = 8, lang: str = "en")

Gets the live status of trains at a particular station.

Parameters:

  • station_code (str): The station code.
  • hrs (int): The number of hours to look ahead for train arrivals. Defaults to 8.
  • lang (str): The language for the response. Defaults to "en".

Returns:

  • dict: The JSON response containing live station information.

Example:

station_status = await wit.live_station("MAS")
print(station_status)