Gov APIindianrail.gov.in ↗
Query Indian Railways station codes, trains between stations, live seat availability (GNWL/RAC/WL), and fare breakdowns via 4 structured endpoints.
What is the Gov API?
The Indian Railways API exposes 4 endpoints that cover station search, reserved train listings between any two stations, live seat availability with status breakdowns across consecutive dates, and per-class fare details — all sourced from indianrail.gov.in. The get_trains_between_stations endpoint returns structured fields including departure and arrival times, available classes, and quota codes, replacing manual lookups on the IRCTC reservation enquiry site.
curl -X GET 'https://api.parse.bot/scraper/f908405b-e5c2-48b7-b976-84771aec0a20/search_stations?query=mumbai' \ -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 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.
"""Walkthrough: Indian Railways train enquiry — bounded, re-runnable."""
from parse_apis.indianrail_gov_in_api import IndianRail, InputNotFound
client = IndianRail()
# Find station codes matching a city name.
for station in client.stations.search(query="mumbai", limit=5):
print(station.station_code, station.station_name)
# Pick the first matching station to use as destination.
dest = client.stations.search(query="mumbai", limit=1).first()
if dest is not None:
# Search trains from Delhi (NDLS) to the discovered station.
try:
for train in client.trains.search(
from_station="NDLS",
to_station=dest.station_code,
journey_date="2026-10-16",
limit=3,
):
print(
train.train_number,
train.train_name,
train.departure_time, "→", train.arrival_time,
f"{train.distance_km} km",
)
# Nested schedule shows which days the train runs.
if train.runs_on.sat:
print(" ^ runs on Saturday")
except InputNotFound:
print("station code not recognized upstream")
# Fetch the full result wrapper for metadata alongside trains.
result = client.train_results.fetch(
from_station="NDLS",
to_station=dest.station_code,
journey_date="2026-10-16",
)
print(f"{result.count} trains, quota codes: {result.quota_codes}")
# Check seat availability for the first train found.
first_train = client.trains.search(
from_station="NDLS",
to_station=dest.station_code,
journey_date="2026-10-16",
limit=1,
).first()
if first_train is not None:
avail = client.availabilities.get(
from_station="NDLS",
to_station=dest.station_code,
train_number=first_train.train_number,
journey_date="2026-10-16",
travel_class="3A",
)
print(avail.status, avail.status_kind)
for day in (avail.availability or [])[:3]:
print(f" {day.date}: {day.status} (count={day.count})")
# Get the fare breakdown for the same train.
fare = client.fares.get(
train_number=first_train.train_number,
from_station="NDLS",
to_station=dest.station_code,
journey_date="2026-10-16",
travel_class="3A",
)
print(f"Total fare: {fare.currency} {fare.total_fare} ({fare.distance_km} km)")
print("exercised: stations.search / trains.search / train_results.fetch / availabilities.get / fares.get")
Finds railway stations whose code or name matches a query, returning the station code to use with get_trains_between_stations. One round trip: the site's full station list is fetched and filtered locally; stations whose code starts with the query come first, then stations whose name contains it. Up to 200 matches are returned; an empty list means no station matched.
| Param | Type | Description |
|---|---|---|
| queryrequired | string | Station code prefix or part of a station name, at least 2 characters, case-insensitive (e.g. 'mumbai' or 'NDL'). |
{
"type": "object",
"fields": {
"count": "number of stations returned (integer, max 200)",
"query": "the query as searched (trimmed)",
"stations": "array of matching stations, each with station_code (short code used by the railway) and station_name"
},
"sample": {
"data": {
"count": 2,
"query": "mumbai",
"stations": [
{
"station_code": "BCT",
"station_name": "MUMBAI CENTRAL"
},
{
"station_code": "MMCT",
"station_name": "MUMBAI CENTRAL"
}
]
},
"status": "success"
}
}About the Gov API
Station Search and Train Discovery
The search_stations endpoint accepts a partial station name or code prefix (minimum 2 characters) and returns up to 200 matches, each with a station_code and station_name. Station codes returned here feed directly into get_trains_between_stations, which requires from_station and to_station codes plus an optional journey_date in ISO YYYY-MM-DD format. Each train in the response carries train_number, train_name, departure_time, arrival_time, the actual boarding and alighting station codes, and an available_classes list. Setting flexible_with_date: true also populates alternate_date_trains with results for nearby dates.
Live Seat Availability
The get_seat_availability endpoint takes a train_number, from_station, to_station, travel_class, and quota code (e.g. GN for General, TQ for Tatkal) and returns an availability array spanning roughly two weeks from the requested journey_date. Each entry includes date, status (raw site string such as GNWL101/WL20), status_kind (available, rac, waitlist, or other), and a numeric count parsed from the status. The top-level status and status_kind fields reflect the specific journey_date queried.
Fare Breakdown
The get_fare endpoint returns a full fare breakdown for one adult on a given train, class, and quota. Response fields include base_fare, reservation_charge, fuel_amount, service_tax, tatkal_fare, total_fare, and distance_km. All amounts are in INR. The currency field is always INR. Quota codes and class codes come from the quota_codes and available_classes fields of a prior get_trains_between_stations response, making the workflow composable across endpoints.
The Gov API is a managed, monitored endpoint for indianrail.gov.in — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when 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 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 planner that shows all reserved trains between two cities on a given date, using departure and arrival times from get_trains_between_stations.
- Display live seat availability for a shortlist of trains, surfacing GNWL, RAC, and WL counts per class from get_seat_availability.
- Compare Tatkal vs General quota fares across travel classes using the base_fare and tatkal_fare fields from get_fare.
- Auto-complete station search in a booking UI with station_code and station_name results from search_stations.
- Alert users when a waitlisted train shows available seats on an alternate date using alternate_date_trains from get_trains_between_stations.
- Estimate total trip cost including service tax and fuel surcharge for multi-leg journeys using get_fare distance_km and total_fare fields.
- Monitor daily seat availability trends across a two-week window using the availability array from get_seat_availability.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 200 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
| Team | $300/mo | 20,000 | 300 req/min |
| Company | $1,000/mo | 100,000 | 500 req/min |
Each endpoint has a fixed posted price per successful call — most fall between 1 and 10 credits — shown on this API's page before you run it. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.