Search trains
search_trainsFull Description
Search trains using either sourceCity/destinationCity or sourceStationCode/destinationStationCode, plus dateOfJourney. City inputs are matched against the station CSV with typo-tolerant resolution and then converted to station codes. Optional classCategory filters the class family: use ac_only for 1A, 2A, 3A, 3E, CC, and EC; use non_ac_only for SL and 2S; use all to clear this filter. Optional availabilityFilter filters visible classes by status: available_only, bookable_only, rac_only, waitlist_only, sold_out_only, or all to clear this filter. Optional minimumAvailableSeats filters visible classes to only currently available inventory with at least that many bookable seats. Use null to clear an inherited seat threshold. Optional departureAfter and departureBefore filter train departure time in HH:MM 24-hour format. Use null to clear an inherited lower or upper time bound. Resolve relative dates such as today or tomorrow into a concrete DD-MM-YYYY date before calling this tool. Do not infer or default dateOfJourney if the user has not given a specific date; ask first. For follow-up refinements after a successful train search, reuse the most recent successful search_trains route, dateOfJourney, passengers, quota, departureAfter, departureBefore, classCategory, availabilityFilter, minimumAvailableSeats, and preferredClasses for any fields the user does not restate. Each successful response echoes the full effectiveQuery and appliedFilterSummaryParts in structuredContent and widget payload metadata. Reuse that canonical state for the next follow-up instead of inferring from prose. New follow-up constraints override reused ones while all unspecified fields stay inherited from the last successful search. Examples: 'show AC trains only' should set classCategory to ac_only; 'show available ones' after that should keep classCategory=ac_only and set availabilityFilter to available_only; 'show me trains after 8 pm' should set departureAfter to 20:00; 'show trains before 6 am' should set departureBefore to 06:00; 'show trains between 8 pm and 6 am' should set departureAfter to 20:00 and departureBefore to 06:00 as an overnight wrap-around window; 'show me trains with more than 20 available seats' should set minimumAvailableSeats to 21 and availabilityFilter to available_only; 'show trains with at least 10 available seats' should set minimumAvailableSeats to 10 and availabilityFilter to available_only; 'show all seat counts again' should clear minimumAvailableSeats by setting it to null; 'show all times again' should clear departureAfter and departureBefore by setting them to null; 'show all the non AC' should set classCategory to non_ac_only and clear narrower inherited availability or class-family filters by setting availabilityFilter=all unless the user restates them; 'show only 3A' should set preferredClasses to 3A and keep classCategory=all unless the user also asked for AC-only; 'make it Tatkal' should set quota to TQ; 'for 2 passengers' should set passengers to 2; 'from NDLS instead' or 'for tomorrow' should replace only the restated route/date values. If no prior successful train search exists for a follow-up-only request, ask for the missing route/date instead of calling the tool. Optional Slack-style filters: classes (overrides preferredClasses), tatkal=true for Tatkal quota, timeSlot (MORNING|AFTERNOON|EVENING|NIGHT|EARLY_MORNING), startTime/endTime/beforeTime/afterTime (HH:mm), minPrice/maxPrice (INR), availabilityStatus (confirmed+RAC only), bookableOnly, hasTravelGuarantee, resetFilters=true to skip post-filters, boardingStation/deboardingStation (station codes), hasAlternates, hasPantry, excludeAvailability (comma list: REGRET,NO_CHANCE,WL,NOT_AVAILABLE,TRAIN_DEPARTED). previousFilters is ignored server-side. Returns the summary and embedded widget together.
Parameters (1 required, 31 optional)
dateOfJourneystringRequired journey date in DD-MM-YYYY. Do not infer or default this value; ask the user when it is missing.
afterTimestringavailabilityFilterstringOptional availability filter. Use available_only for only currently available seats, bookable_only for available or RAC seats, rac_only, waitlist_only, sold_out_only, or all to clear this filter.
allavailable_onlybookable_onlyrac_onlywaitlist_onlysold_out_onlyallavailabilityStatusbooleanbeforeTimestringboardingStationstringbookableOnlybooleanclassCategorystringOptional coach-family filter. Use ac_only for AC classes (1A, 2A, 3A, 3E, CC, EC), non_ac_only for non-AC classes (SL, 2S), or all to clear this filter.
allac_onlynon_ac_onlyallclassesarraydeboardingStationstringdepartureAfterstringOptional lower bound for departure time in HH:MM 24-hour format. Use null to clear an inherited lower bound.
nulldepartureBeforestringOptional upper bound for departure time in HH:MM 24-hour format. Use null to clear an inherited upper bound.
nulldestinationCitystringOptional city name. The backend resolves minor spelling issues and converts it to the best matching station code.
destinationStationCodestringOptional station code. When station codes are known they are used directly.
endTimestringexcludeAvailabilitystringhasAlternatesbooleanhasPantrybooleanhasTravelGuaranteebooleanmaxPricenumberminimumAvailableSeatsintegerOptional minimum count of currently available seats for a visible class. This applies only to classes whose live availability is currently available and exposes a numeric seat count. Use null to clear an inherited threshold.
nullminPricenumberpassengersinteger1preferredClassesarray[]previousFiltersstringquotastringGNTQLDGNresetFiltersbooleansourceCitystringOptional city name. The backend resolves minor spelling issues and converts it to the best matching station code.
sourceStationCodestringOptional station code. When station codes are known they are used directly.
startTimestringtatkalbooleantimeSlotstringMORNINGAFTERNOONEVENINGNIGHTEARLY_MORNING