Delhi NCR Metro API
If you have ever tried to build anything on top of Delhi's metro data, you know it is a patchwork. Official endpoints that disagree, an Aqua Line with no API at all, and map files that change names every deploy. This API cleans that up.
A typed REST API for Delhi NCR. Lines, stations, fares, routes, first and last trains, maps, and notifications for DMRC and NMRC, plus a unified v2 planner that stitches both networks when you cross from Delhi into Noida.
It is a thin, typed wrapper. Pydantic everywhere, one predictable error shape whether you messed up or an upstream did, and the same schemas for Delhi and Noida so your app does not need two code paths. REST and JSON, no auth. If you can fetch, you can use it. /api/v1 mirrors the operators one for one, /api/v2 is the nicer planner that prefers Sarthi and falls back to the legacy route when it has to.
Make your first request
No API key, no ceremony. Plan a journey or list every line with curl. On the v2 planner you can mix station codes from either operator and the API handles the translation for you.
# Plan a journey (v2 · Sarthi with DMRC fallback)
curl '/api/v2/journeys/plan?from_station_code=AIIMS&to_station_code=ASDM&strategy=least-distance'
# List Delhi Metro lines
curl /api/v1/dmrc/lines
Prefer a browser? Use the live playground, open a sample plan, or explore every route in the OpenAPI explorer.
Error envelope
Success returns the payload directly, no wrapper. Failures all look the same, which is on purpose. You get a detail string and, when an upstream is to blame, the status it returned.
{
"detail": "Upstream DMRC request failed.",
"upstream_status_code": 502
}
400 / 404 are caller-visible request errors (upstream_status_code is null). 502 means the upstream DMRC, Sarthi, or NMRC request failed.
API versions
/api/v1 is literal. It mirrors what each operator actually publishes, DMRC's JSON and NMRC's HTML, without pretending they are one system. /api/v2 is the opinionated planner. Sarthi answers first because its data is richer, legacy DMRC fills in when Sarthi fails, and trips that cross from Delhi to Noida are stitched automatically at the Sector 52 to 51 walk.
{
"source": "sarthi",
"fallback_reason": null,
"strategy": "least-distance",
"from_station": {
"name": "AIIMS",
"code": "AIIMS",
"slug": "aiims",
"legacy_code": "AIIMS",
"sarthi_code": "AIIMS"
},
"to_station": {
"name": "Anand Vihar ISBT",
"code": "ASDM",
"slug": "anand-vihar-isbt",
"legacy_code": "ASDM",
"sarthi_code": "ASDM"
},
"total_time": "00:38:26",
"total_distance_km": 18.4,
"fare": {
"normal": 50.0,
"special": 40.0,
"applicable": 50.0,
"breakdown": []
},
"legs": [
{
"kind": "metro",
"network": "dmrc",
"line_name": "Yellow Line",
"line_color": "#FFD200",
"from_station": "AIIMS",
"to_station": "Rajiv Chowk",
"platform_name": "Platform 1",
"direction": "up",
"towards_station": "Samaypur Badli",
"duration": "00:10:00",
"distance_km": 4.2
}
],
"exclude_airport_line": false,
"separate_tickets": false,
"networks": [
"dmrc"
]
}
Health
Liveness probe for deploys and local development.
None.
None.
{
"status": "ok"
}DMRC endpoints (v1)
All the Delhi Metro primitives. Lines, stations, journeys, notifications, and map assets. Open any route for params and a real sample payload.
None.
None.
[
{
"id": 3,
"name": "Yellow Line",
"line_color": "Yellow",
"line_code": "LN3",
"primary_color_code": "#FFD200",
"secondary_color_code": null,
"class_primary": "yellow",
"class_secondary": null,
"start_station": "Samaypur Badli",
"end_station": "HUDA City Centre",
"show_in_frontend": true,
"status": "1"
}
]| Name | Type | Description | |
|---|---|---|---|
line_code | string | required | DMRC line code, e.g. LN3, LN10, LN11. |
None.
[
{
"id": 1,
"station_name": "Samaypur Badli",
"station_code": "SPB",
"station_facility": [],
"metro_lines": [],
"interchange": false,
"status": "1"
}
]None.
| Name | Type | Description | |
|---|---|---|---|
query | string | optional | Station name keyword. Empty returns the full station list. |
filter | string | optional | `all` (default), `least-distance`, or `minimum-interchange`. |
[
{
"id": 42,
"station_name": "Rajiv Chowk",
"station_code": "RC",
"station_facility": [],
"metro_lines": [
{
"line_id": 3,
"line_code": "LN3",
"line_name": "Yellow Line",
"line_color": "Yellow",
"primary_color_code": "#FFD200"
}
]
}
]| Name | Type | Description | |
|---|---|---|---|
station_code | string | required | DMRC station code, e.g. RG, AIIMS, ASDM. |
None.
{
"id": 12,
"station_name": "Rajouri Garden",
"station_code": "RG",
"station_status": "1",
"station_type": "Elevated",
"latitude": "28.649",
"longitude": "77.123",
"metro_lines": [],
"platforms": [],
"gates": [],
"station_facility": []
}None.
| Name | Type | Description | |
|---|---|---|---|
from_station_code | string | required | Origin station code. |
to_station_code | string | required | Destination station code. |
strategy | string | optional | `least-distance` (default) or `minimum-interchange`. |
journey_time | datetime | optional | Optional ISO-8601 departure time for timed planning. |
{
"from_station": "AIIMS",
"to_station": "ASDM",
"total_time": "00:28:00",
"total_stations": 12,
"fare": {
"normal": 40,
"special": 30
},
"route": []
}None.
| Name | Type | Description | |
|---|---|---|---|
from_station_code | string | required | Origin station code. |
to_station_code | string | required | Destination station code. |
journey_time | datetime | optional | Optional ISO-8601 departure. |
{
"from_station": "AIIMS",
"to_station": "ASDM",
"total_time": "00:28:00",
"total_stations": 12,
"fare": {
"normal": 40,
"special": 30
},
"route": []
}None.
| Name | Type | Description | |
|---|---|---|---|
from_station_code | string | required | Origin station code. |
to_station_code | string | required | Destination station code. |
journey_time | datetime | optional | Optional ISO-8601 departure. |
{
"from_station": "AIIMS",
"to_station": "ASDM",
"total_time": "00:28:00",
"total_stations": 12,
"fare": {
"normal": 40,
"special": 30
},
"route": []
}None.
| Name | Type | Description | |
|---|---|---|---|
from_station_code | string | required | Origin station code. |
to_station_code | string | required | Destination station code. |
strategy | string | optional | `least-distance` (default) or `minimum-interchange`. |
See the OpenAPI schema for the exact response model, or try it in the playground.
None.
| Name | Type | Description | |
|---|---|---|---|
from_station_code | string | required | Origin station code. |
to_station_code | string | required | Destination station code. |
journey_time | datetime | optional | Optional ISO-8601 departure. |
See the OpenAPI schema for the exact response model, or try it in the playground.
None.
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
| Name | Type | Description | |
|---|---|---|---|
page_slug | string | required | Page slug from the notifications feed. |
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
None.
| Name | Type | Description | |
|---|---|---|---|
stream | boolean | optional | Send Server-Sent Events (`status`, `error`, `layout`) instead of waiting for JSON. |
See the OpenAPI schema for the exact response model, or try it in the playground.
None.
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
| Name | Type | Description | |
|---|---|---|---|
family | string | required | `network`, `airport-express`, or `rapid-metro`. |
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
| Name | Type | Description | |
|---|---|---|---|
family | string | required | `network`, `airport-express`, or `rapid-metro`. |
| Name | Type | Description | |
|---|---|---|---|
format | string | optional | `image`, `pdf`, or `any` (default). |
See the OpenAPI schema for the exact response model, or try it in the playground.
| Name | Type | Description | |
|---|---|---|---|
family | string | required | `network`, `airport-express`, or `rapid-metro`. |
| Name | Type | Description | |
|---|---|---|---|
format | string | optional | `image`, `pdf`, or `any` (default). |
/download returns a 307 redirect to the upstream static URL. /file streams the bytes through this API.
| Name | Type | Description | |
|---|---|---|---|
family | string | required | `network`, `airport-express`, or `rapid-metro`. |
| Name | Type | Description | |
|---|---|---|---|
format | string | optional | `image`, `pdf`, or `any` (default). |
/download returns a 307 redirect to the upstream static URL. /file streams the bytes through this API.
| Name | Type | Description | |
|---|---|---|---|
asset_id | string | required | Asset id from `/maps/assets`. |
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
NMRC endpoints (v1)
The Aqua Line, same shapes and schemas as Delhi Metro so your client does not branch. The data comes from NMRC's public pages, parsed on the server, with checked-in tables as fallback when the HTML is unavailable.
None.
None.
[
{
"id": 1,
"name": "Aqua Line",
"line_color": "Aqua",
"line_code": "AQUA",
"primary_color_code": "#00A8E8",
"secondary_color_code": null,
"class_primary": "aqua",
"class_secondary": null,
"start_station": "Noida Sector 51",
"end_station": "Depot Station",
"show_in_frontend": true,
"status": "1"
}
]| Name | Type | Description | |
|---|---|---|---|
line_code | string | required | NMRC line code. Currently only `AQUA`. |
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
None.
| Name | Type | Description | |
|---|---|---|---|
query | string | optional | Station name keyword. |
filter | string | optional | `all` (default), `least-distance`, or `minimum-interchange`. |
See the OpenAPI schema for the exact response model, or try it in the playground.
| Name | Type | Description | |
|---|---|---|---|
station_code | string | required | NMRC station code, e.g. NM01. |
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
None.
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
None.
| Name | Type | Description | |
|---|---|---|---|
stream | boolean | optional | Send Server-Sent Events (`status`, `error`, `layout`) instead of waiting for JSON. |
See the OpenAPI schema for the exact response model, or try it in the playground.
None.
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
| Name | Type | Description | |
|---|---|---|---|
family | string | required | Currently only `network` is populated for NMRC. |
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
| Name | Type | Description | |
|---|---|---|---|
family | string | required | Map family, usually `network`. |
| Name | Type | Description | |
|---|---|---|---|
format | string | optional | `image`, `pdf`, or `any`. PDF is empty for NMRC. |
See the OpenAPI schema for the exact response model, or try it in the playground.
| Name | Type | Description | |
|---|---|---|---|
family | string | required | Map family, usually `network`. |
| Name | Type | Description | |
|---|---|---|---|
format | string | optional | `image`, `pdf`, or `any`. |
/download returns a 307 redirect to the upstream static URL. /file streams the bytes through this API.
| Name | Type | Description | |
|---|---|---|---|
family | string | required | Map family, usually `network`. |
| Name | Type | Description | |
|---|---|---|---|
format | string | optional | `image`, `pdf`, or `any`. |
/download returns a 307 redirect to the upstream static URL. /file streams the bytes through this API.
| Name | Type | Description | |
|---|---|---|---|
asset_id | string | required | Asset id from `/nmrc/maps/assets`. |
None.
See the OpenAPI schema for the exact response model, or try it in the playground.
Journey planner (v2)
One clean PlannedJourney no matter who answered. Cross-network trips come back with source: "combined", a walking leg for the Sector 52 to 51 bridge, and fares split in fare.breakdown because the two systems do not share tickets.
None.
| Name | Type | Description | |
|---|---|---|---|
from_station_code | string | required | Origin code in either DMRC or NMRC vocabulary. |
to_station_code | string | required | Destination code in either DMRC or NMRC vocabulary. |
strategy | string | optional | `least-distance` (default) or `minimum-interchange`. |
journey_time | datetime | optional | ISO-8601 departure, Delhi local time. Affects applicable fare. |
exclude_airport_line | boolean | optional | Avoid Airport Express. Honoured by Sarthi only. |
source | string | optional | Pin to `sarthi` or `dmrc` instead of the fallback chain. |
network | string | optional | `dmrc` (default) or `nmrc`. Cross-network plans auto-stitch. |
{
"source": "sarthi",
"fallback_reason": null,
"strategy": "least-distance",
"from_station": {
"name": "AIIMS",
"code": "AIIMS",
"slug": "aiims",
"legacy_code": "AIIMS",
"sarthi_code": "AIIMS"
},
"to_station": {
"name": "Anand Vihar ISBT",
"code": "ASDM",
"slug": "anand-vihar-isbt",
"legacy_code": "ASDM",
"sarthi_code": "ASDM"
},
"total_time": "00:38:26",
"total_distance_km": 18.4,
"fare": {
"normal": 50.0,
"special": 40.0,
"applicable": 50.0,
"breakdown": []
},
"legs": [
{
"kind": "metro",
"network": "dmrc",
"line_name": "Yellow Line",
"line_color": "#FFD200",
"from_station": "AIIMS",
"to_station": "Rajiv Chowk",
"platform_name": "Platform 1",
"direction": "up",
"towards_station": "Samaypur Badli",
"duration": "00:10:00",
"distance_km": 4.2
}
],
"exclude_airport_line": false,
"separate_tickets": false,
"networks": [
"dmrc"
]
}