Railway Routes Between Stations API
stationRoutes(fromCode: string, toCode: string)Description
Find railway paths between two station codes from recorded train routes. Results list the stations along each path and rank paths by the number of trains that serve them, then distance.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
fromCode | ARGUMENT | string | YES | Origin station code, 1-5 letters only |
toCode | ARGUMENT | string | YES | Destination station code, 1-5 letters only |
Code Example
javascript
import { configure, stationRoutes } from "railkit";
configure(process.env.RAILKIT_API_KEY);
const result = await stationRoutes("NDLS", "DLI");
if (result.success) {
for (const route of result.data.routes) {
console.log(route.rank, route.distanceKm, route.stations.map((station) => station.code));
}
}Response Example