RedRail

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 redrail
 
redrail = redrail.RedRail()

Methods

pnr_status(pnr: str, mobile: str = "")

Gets the PNR status from the RedRail API.

Parameters:

  • pnr (str): The PNR number.
  • mobile (str): The mobile number associated with the PNR (optional).

Returns:

  • dict: The JSON response containing PNR status information.

Example:

status = await redrail.pnr_status("1234567890")
print(status)

train_schedule(train_no: str)

Gets the schedule for a train from the RedRail API.

Parameters:

  • train_no (str): The train number.

Returns:

  • dict: The JSON response containing train schedule information.

Example:

schedule = await redrail.train_schedule("12625")
print(schedule)

coach_position(train_no: str, stn: str)

Gets the coach position for a train at a station from the RedRail API.

Parameters:

  • train_no (str): The train number.
  • stn (str): The station code.

Returns:

  • dict: The JSON response containing coach position information.

Example:

position = await redrail.coach_position("12625", "MAS")
print(position)

search_routes(src: str, dst: str, doj: str)

Searches for routes between two stations on a given date from the RedRail API.

Parameters:

  • src (str): The source station code.
  • dst (str): The destination station code.
  • doj (str): The date of journey in the format 'yyyymmdd'.

Returns:

  • dict: The JSON response containing route search results.

Example:

routes = await redrail.search_routes("NDLS", "MAS", "20231215")
print(routes)

user_status(irctc_username: str)

Gets the user status from the RedRail API.

Parameters:

  • irctc_username (str): The IRCTC username.

Returns:

  • dict: The JSON response containing user status information.

Example:

status = await redrail.user_status("your_irctc_username")
print(status)

get_live_train_status(train_no: str)

Gets the live status of a train from the RedRail API.

Parameters:

  • train_no (str): The train number.

Returns:

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

Example:

status = await redrail.get_live_train_status("12625")
print(status)