GET

/routes/trains

Get API key

Lists direct trains between two stations, in departure-time order, plus alternatives that board or alight nearby.

Request

curl "https://api.traindekho.live/v1/routes/trains?from=NDLS&to=MMCT" \
  -H "X-API-Key: YOUR_API_KEY"
NameInRequiredDescription
fromqueryyesOrigin station code.
toqueryyesDestination station code.
datequerynoWhen set, only trains that run on this journey date are returned.

Responses

200

Direct trains in departure-time order, plus alternatives that board or alight nearby.

{
  "direct_trains": [
    {
      "train_no": "12951",
      "name": "Mumbai Rajdhani",
      "type": "RAJ",
      "departure_time": "17:05",
      "arrival_time": "08:32",
      "duration_minutes": 927,
      "distance_km": 1384,
      "day_offset": 1,
      "days_of_run": {
        "sun": false,
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true
      },
      "classes": [
        "1A",
        "2A",
        "3A"
      ],
      "stops_between": 6
    }
  ],
  "alternatives": []
}
400

A path or query value is missing or has the wrong format.

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Request is invalid."
  }
}
401

The API key is missing, unknown, expired, or revoked.

{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Authentication is required."
  }
}
403

The credential is valid and does not include this API.

{
  "error": {
    "code": "FORBIDDEN",
    "message": "You do not have access to this API."
  }
}
429

The caller exceeded a rate limit or a quota. Wait for Retry-After seconds before retrying.

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "API request limit exceeded"
  }
}
500

The request could not be completed.

{
  "error": {
    "code": "INTERNAL_ERROR",
    "message": "The request could not be completed."
  }
}