# Railway stations API

> Indian Railways station codes to stations, and back.

About 4,000 stations with their code, state, railway zone and elevation, from Wikipedia's list of railway stations in India. No official open list exists; this one is kept by volunteers, so some codes are out of date and many entries lack a state or zone.

Base URL `https://api.dharun.dev`. No API key. Answers are JSON, `{ "data": ..., "meta": { ... } }`, and errors are `{ "error": { "code", "message" } }` with a matching HTTP status. Rate limit: 600 requests a minute per client.

## Station for a code

`GET /v1/stations/{code}`

Parameters:

- `code` (path, required): Station code, such as MAS or NDLS.

Example: https://api.dharun.dev/v1/stations/MAS

Response:

```json
{
  "data": {
    "code": "MAS",
    "name": "Puratchi Thalaivar Dr. M.G. Ramachandran Central Railway Station",
    "stateCode": "TN",
    "state": "Tamil Nadu",
    "zone": {
      "code": "SR",
      "name": "Southern"
    },
    "elevationM": 3
  },
  "meta": {
    "source": {
      "name": "List of railway stations in India",
      "url": "https://en.wikipedia.org/w/index.php?title=List_of_railway_stations_in_India&oldid=1371613797",
      "licence": "CC BY-SA 4.0",
      "version": "revision 1371613797",
      "retrieved": "2026-10-13",
      "attribution": "Station codes adapted from the Wikipedia article \"List of railway stations in India\", licensed CC BY-SA 4.0. This dataset is shared under the same licence."
    },
    "note": "From a community-kept list: a few codes are out of date (Mumbai CSMT is listed under its old code CSTM) and many stations lack a state or zone."
  }
}
```

## Search stations

`GET /v1/stations`

By name (an exact code comes first, then names starting with the text), state or zone.

Parameters:

- `q` (query): Part of a station name, or a code.
- `state` (query): State code or name, for example TN or Tamil Nadu.
- `zone` (query): Zone code, such as SR. See /v1/stations/zones.
- `limit` (query): Results per page, 1 to 100.
- `offset` (query): Results to skip.

Example: https://api.dharun.dev/v1/stations?q=chennai

Response, with lists and long text shortened:

```json
{
  "data": [
    {
      "code": "MSB",
      "name": "Chennai Beach",
      "stateCode": "TN",
      "state": "Tamil Nadu",
      "zone": null,
      "elevationM": null
    },
    {
      "code": "MS",
      "name": "Chennai Egmore",
      "stateCode": "TN",
      "state": "Tamil Nadu",
      "zone": null,
      "elevationM": null
    },
    {
      "code": "MSF",
      "name": "Chennai Fort",
      "stateCode": "TN",
      "state": "Tamil Nadu",
      "zone": null,
      "elevationM": null
    }
  ],
  "meta": {
    "total": 5,
    "limit": 20,
    "offset": 0,
    "source": {
      "name": "List of railway stations in India",
      "url": "https://en.wikipedia.org/w/index.php?title=List_of_railway_stations_in_India&oldid=1371613797",
      "licence": "CC BY-SA 4.0",
      "version": "revision 1371613797",
      "retrieved": "2026-10-13",
      "attribution": "Station codes adapted from the Wikipedia article \"List of railway stations in India\", licensed CC BY-SA 4.0. This dataset is shared under the same licence."
    },
    "note": "From a community-kept list: a few codes are out of date (Mumbai CSMT is listed under its old code CSTM) and many stations lack a state or zone."
  }
}
```

## Railway zones

`GET /v1/stations/zones`

Example: https://api.dharun.dev/v1/stations/zones

Response, with lists and long text shortened:

```json
{
  "data": [
    {
      "code": "CR",
      "name": "Central"
    },
    {
      "code": "ER",
      "name": "Eastern"
    },
    {
      "code": "ECR",
      "name": "East Central"
    }
  ],
  "meta": {
    "total": 19
  }
}
```

## Data source

- [List of railway stations in India](https://en.wikipedia.org/w/index.php?title=List_of_railway_stations_in_India&oldid=1371613797), revision 1371613797, retrieved 2026-10-13. Licence: CC BY-SA 4.0. Station codes adapted from the Wikipedia article "List of railway stations in India", licensed CC BY-SA 4.0. This dataset is shared under the same licence.
