Train Route Geometry

GET/v1/trains/{number}/route

Train route geometry

Description

Returns the route geometry for a train. **Format options (`format` param):** - `geojson` (default) — GeoJSON `LineString` feature. Ready for Leaflet, MapLibre, QGIS, geojson.io. - `polyline` — [Google encoded polyline](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) (precision 5). Smallest payload (~8KB avg). Decode with any standard polyline library. - `coordinates` — Raw `[[lat, lng], ...]` array. For custom renderers. **Stops (`stops` param):** - Pass `stops=true` to include all station stops (code, name, lat, lng, sequence) alongside the geometry. Useful for drawing station markers on the route in a single request.

Parameters

NameInTypeRequiredDescription
numberpathstringYes5-digit train number
formatquerypolyline | geojson | coordinatesNoResponse format for the geometry. Default: `geojson` Default: geojson
stopsquerytrue | falseNoInclude station stops (code, name, lat, lng) alongside the geometry. Default: `false` Default: false

Code Examples

CURL
curl -X GET "https://api.railradar.in/v1/trains/12919/route?format=geojson&stops=true" \
  -H "Authorization: Bearer rr_live_YOUR_API_KEY"

Example Response

JSON200 OK
{
  "success": true,
  "data": {
    "trainNumber": "12919",
    "format": "geojson",
    "geojson": {
      "type": "Feature",
      "properties": {
        "trainNumber": "12919"
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            75.86,
            22.72
          ],
          [
            75.78,
            23.17
          ],
          [
            76.71,
            23.18
          ]
        ]
      }
    },
    "stops": [
      {
        "sequence": 1,
        "code": "INDB",
        "name": "Indore Junction",
        "lat": 22.72,
        "lng": 75.86
      },
      {
        "sequence": 2,
        "code": "UJN",
        "name": "Ujjain Junction",
        "lat": 23.17,
        "lng": 75.78
      }
    ]
  },
  "meta": {
    "traceId": "550e8400-e29b-41d4-a716-446655440000",
    "timestamp": "2026-06-22T12:30:00+05:30",
    "executionTime": 38,
    "source": "database"
  }
}

Try it Out

Login to test this endpoint

Sign in to pre-fill your API key and send live requests directly from the browser.

Sign in →

Error Codes

StatusMeaning
400Bad Request — invalid or missing parameter
401Unauthorized — missing or invalid Authorization Bearer token
404Not Found — train/station not found (or no results)
429Too Many Requests — rate limit exceeded
503Service Unavailable — upstream data source temporarily down

Error Response Examples

JSON Error Envelope404 Not Found
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Resource not found (e.g. Train 12919 not found on journey date 2026-06-22)"
  },
  "meta": {
    "traceId": "9772f1c9-6ec6-4d9f-b269-a5210f33ec73",
    "timestamp": "2026-06-22T08:14:00+05:30",
    "executionTime": 5,
    "source": "database"
  }
}