Gov APIenquiry.indianrail.gov.in ↗
Access Indian Railways train schedules, station lists, and trains between stations via 5 endpoints covering the enquiry.indianrail.gov.in portal.
What is the Gov API?
The Indian Railways Enquiry API provides 5 endpoints covering train listings, station lookups, and schedule data from enquiry.indianrail.gov.in. The get_trains_between_stations endpoint returns departure/arrival times and class availability for a given source station code, destination station code, and travel date. Reference lists for all trains and all stations are available without any captcha requirement.
No input parameters required.
curl -X GET 'https://api.parse.bot/scraper/ca465a89-6791-41cd-aead-47677fe7a343/get_trains' \ -H 'X-API-Key: $PARSE_API_KEY'
Typed, relational, agent-ready
A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.
- Fully typed · autocompletes
- Objects link to objects
- Typed errors & pagination
Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:
uv add parse-sdk uv run parse init uv run parse add --marketplace enquiry-indianrail-gov-in-api
uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.
from parse_apis.indian_rail_enquiry_api import IndianRail, Train, Station, Captcha, TrainSchedule, ScheduleStop, TrainBetweenStations, CaptchaNotMatched
indian_rail = IndianRail()
# List all available trains
for train in indian_rail.trains.list(limit=5):
print(train.number, train.name)
# List all stations
for station in indian_rail.stations.list(limit=5):
print(station.name, station.code)
# Fetch a captcha image for session initialization
captcha = indian_rail.captchas.fetch()
print(captcha.captcha_image, captcha.content_type)
# Get train schedule using a constructed Train instance
train = indian_rail.train("12002")
try:
schedule = train.schedule(captcha="solved_answer")
print(schedule.train_name, schedule.train_number)
for stop in schedule.station_list:
print(stop.station_name, stop.arrival_time, stop.departure_time, stop.halt_time, stop.distance)
except CaptchaNotMatched:
print("Captcha answer was incorrect, fetch a new captcha and retry")
# Search trains between two stations
for result in indian_rail.trainbetweenstationses.search(source="NDLS", dest="BBA", date="15-06-2026", captcha="solved_answer"):
print(result.train_number, result.train_name, result.departure_time, result.arrival_time)
Returns the complete list of trains available on Indian Railways with their numbers and names. No parameters required. The response contains thousands of trains in 'NUMBER - NAME' format.
No input parameters required.
{
"type": "object",
"fields": {
"trains": "array of strings, each in format 'TRAIN_NUMBER - TRAIN_NAME'"
},
"sample": {
"data": {
"trains": [
"20822 - PUNE HUMSAFAR",
"22647 - KRBA TVCN SF EXP",
"19209 - BVC OKHA EXP"
]
},
"status": "success"
}
}About the Gov API
What the API Covers
Five endpoints expose the core data from the Indian Railways enquiry portal. get_trains returns a flat array of strings in TRAIN_NUMBER - TRAIN_NAME format, covering every train in the national network. get_stations returns an equivalent list in STATION_NAME - STATION_CODE format — these station codes are the values you pass as source and dest in downstream queries.
Captcha-Gated Endpoints
Two endpoints — get_train_schedule and get_trains_between_stations — require a solved captcha before they will return data. The flow is: call get_captcha first; it returns a captchaImage field containing a base64-encoded PNG and a contentType field. Decode the image, solve it, and pass the answer as the captcha parameter alongside the session_id and encryption_key values to whichever search endpoint you need.
Schedule and Search Responses
get_train_schedule accepts a train_no (e.g. '12002') and returns trainName, trainNumber, and a stationList array. Each element of stationList carries stationName, arrivalTime, departureTime, haltTime, and cumulative distance. get_trains_between_stations accepts source, dest, and date (in dd-mm-yyyy format) and returns a trainBtwnStnsList array where each object includes trainNumber, trainName, departureTime, arrivalTime, and available class information for that service on that date.
Session Handling
The captcha step initialises a session. The session_id and encryption_key returned from that flow must be forwarded with schedule and between-stations queries. Each captcha is tied to one session, so a new get_captcha call is required for each independent search session.
The Gov API is a managed, monitored endpoint for enquiry.indianrail.gov.in — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when enquiry.indianrail.gov.in changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official enquiry.indianrail.gov.in API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Build a train route planner that resolves station names to codes via
get_stationsand then queriesget_trains_between_stationsfor available services. - Generate a timetable display for a specific train using the
stationListfromget_train_schedule, showing halt durations and cumulative distance. - Populate autocomplete fields in a booking UI using the full train and station lists from
get_trainsandget_stations. - Check class availability on a given travel date between two stations using the class information in
trainBtwnStnsList. - Aggregate departure and arrival times across multiple trains on a corridor to find the fastest or most convenient services.
- Validate that a station code exists before submitting it to a schedule query, by cross-referencing the
get_stationslist.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does Indian Railways have an official developer API?+
What does `get_trains_between_stations` return beyond just train names?+
trainBtwnStnsList array includes trainNumber, trainName, departureTime, arrivalTime, and available class information for the queried date. The response is scoped to the specific source-dest pair and date you supply, so you need a separate call per route-date combination.Why do I need to call `get_captcha` before schedule searches?+
get_train_schedule and get_trains_between_stations endpoints require a session initialised by a prior get_captcha call. get_captcha returns a base64 PNG (captchaImage) that must be solved; the answer, along with session_id and encryption_key, is then passed to the search endpoint. get_trains and get_stations do not require this step.Does the API return live running status or platform numbers for trains?+
Are trains from all Indian Railways zones included in `get_trains`?+
get_trains endpoint returns all trains listed in the enquiry.indianrail.gov.in database, which covers the national network. However, very recently added or withdrawn trains may not immediately reflect in the list, as the data reflects the current state of the portal's records.