NAV
shell

Introduction

Welcome to RailwayAPI Documentation. Our API is organized around HTTP GET Requests. You can use our API to get information regarding LIVE Train Status, PNR Status, Train Schedule among other things.

Authentication

An Example:

curl http://api.railwayapi.com/route/train/12555/apikey/myapikey/

Make sure to replace myapikey with your API key.

You must have an API key to use the API functions. You can get one by completing the registration. You will be sent your secret key in your email.

Your API key must be included in all the requests.

API Functions

Live Train Status

curl "http://api.railwayapi.com/live/train/12046/doj/20151119/apikey/myapikey/"

JSON Response:

{
    "response_code": 200,
    "error": "",
    "position": "Train has reached Destination and late by 5 minutes.",
    "train_number": "12046",
    "route": [
        {
            "no": 1,
            "station_": {
                "name": "CHANDIGARH",
                "code": "CDG"
            },
            "has_arrived": false,
            "has_departed": true,
            "day": 0,
            "distance": 0,
            "scharr": "Source",
            "schdep": "12:00",
            "actarr": "00:00",
            "actdep": "12:00",
            "scharr_date": "19 Nov 2015",
            "actarr_date": "19 Nov 2015",
            "latemin": 0
        },
        {
            "no": 2,
            "station_": {
                "name": "AMBALA CANT JN",
                "code": "UMB"
            },
            "has_arrived": true,
            "has_departed": true,
            "day": 0,
            "distance": 67,
            "scharr": "12:40",
            "schdep": "12:42",
            "actarr": "12:40",
            "actdep": "12:42",
            "scharr_date": "19 Nov 2015",
            "actarr_date": "19 Nov 2015",
            "latemin": 0
        },
        {
            "no": 3,
            "station_": {
                "name": "NEW DELHI",
                "code": "NDLS"
            },
            "has_arrived": true,
            "has_departed": false,
            "day": 0,
            "distance": 265,
            "scharr": "15:25",
            "schdep": "Destination",
            "actarr": "15:30",
            "actdep": "00:00",
            "scharr_date": "19 Nov 2015",
            "actarr_date": "19 Nov 2015",
            "latemin": 5
        }
    ]
}

Purpose:

Get Live running status of Train.

Request URL

http://api.railwayapi.com/live/train/<train number>/doj/<yyyymmdd>/apikey/<apikey>/

URL Parameters

Parameter Description
live Function name.
train The Train number.
doj Day the Train started in YYYYMMDD format.
apikey Your API Key.

Special Error Codes

Code Meaning
510 Train not scheduled to run on the given date.

PNR Status

curl "http://api.railwayapi.com/pnr_status/pnr/1234567890/apikey/myapikey/"

JSON Response:

{
    "response_code": 200,
    "error": false,
    "train_name": "KCG YPR EXP",
    "train_num": "17603",
    "pnr": "1234567890",
    "failure_rate": 19.346153846153847,
    "doj": "20-8-2015",
    "chart_prepared": "Y",
    "class": "SL",
    "total_passengers": 2,
    "train_start_date": {
        "month": 8,
        "year": 2015,
        "day": 20
    },
    "from_station": {
        "code": "KCG",
        "name": "KACHEGUDA"
    },
    "boarding_point": {
        "code": "KCG",
        "name": "KACHEGUDA"
    },
    "to_station": {
        "code": "YPR",
        "name": "YESVANTPUR JN"
    },
    "reservation_upto": {
        "code": "YPR",
        "name": "YESVANTPUR JN"
    },
    "passengers": [
        {
            "no": 1,
            "booking_status": "S7,58,GN",
            "current_status": "S7,58",
            "coach_position": 9
        },
        {
            "no": 2,
            "booking_status": "S7,59,GN",
            "current_status": "S7,59",
            "coach_position": 9
        }
    ]
}

Purpose

Get PNR status details.

Request URL

http://api.railwayapi.com/pnr_status/pnr/<pnr no>/apikey/<apikey>/

URL Parameters

Parameter Description
pnr_status Function name.
pnr PNR number to query.
apikey Your API Key.

Special Error Codes

Code Meaning
410 Flushed PNR / PNR not yet generated
404 Service Down / Source not responding

Train Route

curl http://api.railwayapi.com/route/train/12046/apikey/myapikey/

JSON Response:

{
    "response_code": 200,
    "route": [
        {
            "no": 1,
            "distance": 0,
            "day": 1,
            "halt": 0,
            "route": 1,
            "code": "CDG",
            "fullname": "CHANDIGARH",
            "lat": 30.7333148,
            "lng": 76.7794179,
            "state": "Chandigarh",
            "scharr": "Source",
            "schdep": "12:00"
        },
        {
            "no": 2,
            "distance": 68,
            "day": 1,
            "halt": 2,
            "route": 1,
            "code": "UMB",
            "fullname": "AMBALA CANT JN",
            "lat": 30.3781788,
            "lng": 76.7766974,
            "state": "Haryana",
            "schdep": "12:42",
            "scharr": "12:40"
        },
        {
            "no": 3,
            "distance": 266,
            "day": 1,
            "halt": 0,
            "route": 1,
            "code": "NDLS",
            "fullname": "NEW DELHI",
            "lat": 28.6139,
            "lng": 77.2089,
            "state": "Delhi",
            "schdep": "Destination",
            "scharr": "15:20"
        }
    ],
    "train": {
        "number": "12046",
        "name": "CDG NDLS SHTBDI",
        "days": [
            {
                "day-code": "SUN",
                "runs": "N"
            },
            {
                "day-code": "MON",
                "runs": "Y"
            },
            {
                "day-code": "TUE",
                "runs": "Y"
            },
            {
                "day-code": "WED",
                "runs": "Y"
            },
            {
                "day-code": "THU",
                "runs": "Y"
            },
            {
                "day-code": "FRI",
                "runs": "Y"
            },
            {
                "day-code": "SAT",
                "runs": "Y"
            }
        ],
        "classes": [
            {
                "available": "N",
                "class-code": "3A"
            },
            {
                "available": "Y",
                "class-code": "CC"
            },
            {
                "available": "N",
                "class-code": "SL"
            },
            {
                "available": "N",
                "class-code": "2S"
            },
            {
                "available": "N",
                "class-code": "3E"
            },
            {
                "available": "N",
                "class-code": "2A"
            },
            {
                "available": "Y",
                "class-code": "1A"
            },
            {
                "available": "N",
                "class-code": "FC"
            }
        ]
    }
}

Purpose

Get details about the Stations in a Train’s route.

Request URL

http://api.railwayapi.com/route/train/<train number>/apikey/<apikey>/

URL Parameters

Parameter Description
route Function name.
train The Train number to query.
apikey Your API Key.

Seat Availability

curl http://api.railwayapi.com/check_seat/train/12001/source/BPL/dest/NDLS/date/14-10-2014/class/CC/quota/GN/apikey/myapikey/

JSON Response:

{
    "response_code": 200, 
    "train_number": "12001", 
    "train_name": "NDLS SHATABDI E",
    "failure_rate": 31.346153846153847,
    "error": false, 
    "from": {
        "lat": 23.2599333, 
        "name": "BHOPAL  JN", 
        "lng": 77.412615, 
        "code": "BPL"
    }, 
    "class": {
        "class_name": "AC CHAIR CAR", 
        "class_code": "CC"
    }, 
    "to": {
        "lat": 30.6016778, 
        "name": "NEW DELHI", 
        "lng": -98.3488272, 
        "code": "NDLS"
    }, 
    "availability": [
        {
            "date": "14-10-2014", 
            "status": "AVAILABLE 364"
        }, 
        {
            "date": "15-10-2014", 
            "status": "AVAILABLE 361"
        }, 
        {
            "date": "16-10-2014", 
            "status": "AVAILABLE 284"
        }, 
        {
            "date": "17-10-2014", 
            "status": "AVAILABLE 351"
        }, 
        {
            "date": "18-10-2014", 
            "status": "AVAILABLE 303"
        }, 
        {
            "date": "19-10-2014", 
            "status": "AVAILABLE 329"
        }
    ], 
    "quota": {
        "quota_name": "GENERAL QUOTA", 
        "quota_code": "GN"
    }
}

Purpose

Get Train Seat Availability.

Request URL

http://api.railwayapi.com/check_seat/train/<train number>/source/<source code>/dest/<dest code>/date/<doj in DD-MM-YYYY>/class/<class code>/quota/<quota code>/apikey/<apikey>/

URL Parameters

Parameter Description
check_seat Function name.
train The Train number to query.
source Source station code.
dest Destination station code.
date Date in DD-MM-YYYY format.
class Class Code
quota Quota Code
apikey Your API Key.

Trains Between Stations

curl http://api.railwayapi.com/between/source/gkp/dest/ngp/date/27-08/apikey/myapikey/

JSON Response:

{
    "response_code": 200,
    "total": 1,
    "train": [
        {
            "no": 1,
            "name": "RAPTI SAGAR EXP",
            "number": "12511",
            "src_departure_time": "06:35",
            "dest_arrival_time": "03:50",
            "travel_time": "21:15",
            "from": {
                "name": "GORAKHPUR JN",
                "code": "GKP"
            },
            "to": {
                "name": "NAGPUR",
                "code": "NGP"
            },
            "classes": [
                {
                    "class-code": "FC",
                    "available": "N"
                },
                {
                    "class-code": "3E",
                    "available": "N"
                },
                {
                    "class-code": "CC",
                    "available": "N"
                },
                {
                    "class-code": "SL",
                    "available": "Y"
                },
                {
                    "class-code": "2S",
                    "available": "N"
                },
                {
                    "class-code": "2A",
                    "available": "Y"
                },
                {
                    "class-code": "3A",
                    "available": "Y"
                },
                {
                    "class-code": "1A",
                    "available": "N"
                }
            ],
            "days": [
                {
                    "day-code": "MON",
                    "runs": "N"
                },
                {
                    "day-code": "TUE",
                    "runs": "N"
                },
                {
                    "day-code": "WED",
                    "runs": "N"
                },
                {
                    "day-code": "THU",
                    "runs": "Y"
                },
                {
                    "day-code": "FRI",
                    "runs": "Y"
                },
                {
                    "day-code": "SAT",
                    "runs": "N"
                },
                {
                    "day-code": "SUN",
                    "runs": "Y"
                }
            ]
        }
    ]
}

Purpose

Get Seat Availability status of a Train.

Request URL

http://api.railwayapi.com/between/source/<station code>/dest/<station code>/date/dd-mm/apikey/<apikey>/

URL Parameters

Parameter Description
between Function name.
source Source station code.
dest Destination station code.
date Date in DD-MM format.
apikey Your API Key.

Train Name/Number

curl http://api.railwayapi.com/name_number/train/bhopal/apikey/myapikey/

JSON Response:

{
    "response_code": 200,
    "train": {
        "number": "12155", 
    "name": "BHOPAL EXPRESS",
        "days": [
            {
                "day-code": "SUN", 
                "runs": "Y"
            }, 
            {
                "day-code": "MON", 
                "runs": "Y"
            }, 
            {
                "day-code": "TUE", 
                "runs": "Y"
            }, 
            {
                "day-code": "WED", 
                "runs": "Y"
            }, 
            {
                "day-code": "THU", 
                "runs": "Y"
            }, 
            {
                "day-code": "FRI", 
                "runs": "Y"
            }, 
            {
                "day-code": "SAT", 
                "runs": "Y"
            }
        ] 
    }
}

Purpose

Get Train name using number and vice versa.

Request URL

http://api.railwayapi.com/name_number/train/<name or number>/apikey/<apikey>/

URL Parameters

Parameter Description
name_numer Function name.
train Train name or number.
apikey Your API Key.

Train Fare Enquiry

curl http://api.railwayapi.com/fare/train/12555/source/gkp/dest/ndls/age/18/quota/PT/doj/23-11-2014/apikey/myapikey/

JSON Response:

{
    "response_code":200,
    "failure_rate": 18.214153846153847,
    "train": {
        "number": "12555",
        "name": "GORAKDAM EXPRES"
    },
    "from": {
        "code": "GKP",
        "name": "GORAKHPUR JN"
    },
    "quota": {
        "code": "PT",
        "name": "Premium Tatkal Quota"
    },
    "to": {
        "code": "NDLS",
        "name": "NEW DELHI"
    },
    "fare": [
        {
            "code": "1A",
            "name": "FIRST AC",
            "fare": "2695"
        },
        {
            "code": "2A",
            "name": "SECOND AC",
            "fare": "2005"
        },
        {
            "code": "3A",
            "name": "THIRD AC",
            "fare": "1425"
        },
        {
            "code": "SL",
            "name": "SLEEPER CLASS",
            "fare": "540"
        }
    ]
}

Purpose

Get Fares of Train.

Request URL

http://api.railwayapi.com/fare/train/<train number>/source/<source station code>/dest/<dest station code>/age/<age>/quota/<quota>/doj/<doj>/apikey/<apikey>/

URL Parameters

Parameter Description
fare Function name.
train Train number.
source Source station code.
dest Destination station code.
age Age of the passenger.
quota Quota Code
doj Date of journey in dd-mm-yyyy format.
apikey Your API Key.

Train Arrivals at Station

curl http://api.railwayapi.com/arrivals/station/cdg/hours/2/apikey/myapikey/

JSON Response:

{
    "response_code": 200,
    "station": "CDG",
    "total": 2,
    "train": [
        {
            "scharr": "05:10",
            "delayarr": "RT",
            "schdep": "05:20",
            "name": "BARMER KLK EXP",
            "actdep": "05:20",
            "delaydep": "RT",
            "actarr": "05:10",
            "number": "14888"
        },
        {
            "scharr": "04:55",
            "delayarr": "RT",
            "schdep": "DSTN",
            "name": "JP-CDG INTERCITY EXP",
            "actdep": "DSTN",
            "delaydep": "RT",
            "actarr": "04:55",
            "number": "19717"
        }
    ]
}

Purpose

Get list of Trains arriving on a station within given hours with their scheduled time and live status included.

Request URL

http://api.railwayapi.com/arrivals/station/<station code>/hours/<hours to search within>/apikey/<apikey>/

URL Parameters

Parameter Description
arrivals Function name.
station Station code.
hours Window time in hours in which to search for train arrivals. Valid values: 2 or 4
apikey Your API Key.

Cancelled Trains

curl http://api.railwayapi.com/cancelled/date/26-12-2015/apikey/myapikey/

JSON Response:

{
    "response_code": 200,
    "last_updated": {
        "date": "2015-12-27",
        "time": "01:32:13"
    },
    "trains": [
        {
            "train": {
                "number": "04921",
                "start_time": "04:45",
                "name": "SRE-UMB MEMU SPECIAL",
                "type": "HSP"
            },
            "dest": {
                "code": "UMB",
                "name": "AMBALA CANT JN"
            },
            "source": {
                "code": "SRE",
                "name": "SAHARANPUR"
            }
        },
        {
            "train": {
                "number": "04922",
                "start_time": "20:45",
                "name": "UMB-SRE MEMU SPECIAL",
                "type": "HSP"
            },
            "dest": {
                "code": "SRE",
                "name": "SAHARANPUR"
            },
            "source": {
                "code": "UMB",
                "name": "AMBALA CANT JN"
            }
        }
    ]
}

Purpose

Get list of all Cancelled Trains on a particular day.

Request URL

http://api.railwayapi.com/cancelled/date/<date in dd-mm-yyyy>/apikey/<apikey>/

URL Parameters

Parameter Description
cancelled Function name.
date Date in DD-MM-YYYY format.
apikey Your API Key.

Rescheduled Trains

curl http://api.railwayapi.com/rescheduled/date/26-12-2015/apikey/myapikey/
{
    "response_code": 200,
    "trains": [
        {
            "number": "01056",
            "name": "BSB-CSTM UNRESERVED SPL",
            "to": {
                "code": "CSTM",
                "name": "MUMBAI CST"
            },
            "from": {
                "code": "BSB",
                "name": "VARANASI JN"
            },
            "rescheduled_date": "25-Apr",
            "rescheduled_time": "12:50",
            "time_diff": "04:50"
        },
        {
            "number": "05102",
            "name": "ANVT-CPR SUMMER SPL",
            "to": {
                "code": "CPR",
                "name": "CHHAPRA"
            },
            "from": {
                "code": "ANVT",
                "name": "ANAND VIHAR TERMINAL"
            },
            "rescheduled_date": "25-Apr",
            "rescheduled_time": "15:20",
            "time_diff": "01:25"
        }
    ]
}

Purpose

Get list of Rescheduled Trains on the given date.

Request URL

http://api.railwayapi.com/rescheduled/date/<date in dd-mm-yyyy>/apikey/<apikey>/

URL Parameters

Parameter Description
rescheduled Function name.
date Date in DD-MM-YYYY format.
apikey Your API Key.

Station Name to Code

curl http://api.railwayapi.com/name_to_code/station/luckn/apikey/myapikey/

JSON Response:

{
    "response_code": 200, 
    "stations": [
        {
            "lat": 26.8465108, 
            "fullname": "Lucknow Nr", 
            "code": "LKO", 
            "lng": 80.9466832, 
            "state": "Uttar Pradesh"
        }, 
        {
            "lat": 26.8465108, 
            "fullname": "Lucknow Ne", 
            "code": "LJN", 
            "lng": 80.9466832, 
            "state": "Uttar Pradesh"
        }, 
        {
            "lat": 26.7993186, 
            "fullname": "Bargawan", 
            "code": "BRGW", 
            "lng": 80.8972673, 
            "state": "Uttar Pradesh"
        }, 
        {
            "lat": 26.8700844, 
            "fullname": "Badshahnagar", 
            "code": "BNZ", 
            "lng": 80.9591296, 
            "state": "Uttar Pradesh"
        }
   ]
}

Purpose

Get station details of given station and nearby stations using station name with automatic name completion.

Request URL

http://api.railwayapi.com/name_to_code/station/<station name>/apikey/<apikey>/

URL Parameters

Parameter Description
name_to_code Function name.
station Station name.
apikey Your API Key.

Station Code to Name

curl http://api.railwayapi.com/code_to_name/code/gkp/apikey/myapikey/

JSON Response:

{
    "response_code": 200, 
    "stations": [
        {
            "lng": 83.3731675, 
            "lat": 26.7605545, 
            "code": "GKP", 
            "state": "Uttar Pradesh", 
            "fullname": "Gorakhpur Jn"
        }, 
        {
            "lng": 83.5842775, 
            "lat": 26.6492695, 
            "code": "CC", 
            "state": "Uttar Pradesh", 
            "fullname": "Chauri Chaura"
        }, 
        {
            "lng": 83.2142269, 
            "lat": 26.758544, 
            "code": "SWA", 
            "state": "Uttar Pradesh", 
            "fullname": "Sahjanwa"
        }, 
        {
            "lng": 83.3742644, 
            "lat": 26.7401226, 
            "code": "DDP", 
            "state": "Uttar Pradesh", 
            "fullname": "Daudpur"
        }
    ]
}

Purpose

Get Station details of the passed Station and other nearby Stations using Station code

Request URL

http://api.railwayapi.com/code_to_name/code/<station code>/apikey/<apikey>/

URL Parameters

Parameter Description
code_to_name Function name.
code Station code.
apikey Your API Key.

Station Autocomplete Suggest

curl http://api.railwayapi.com/suggest_station/name/mum/apikey/myapikey/

JSON Response:

{
    "response_code": 200,
    "total": 2,
    "station": [
        {
            "fullname": "MUMBAI CST",
            "code": "CSTM"
        },
        {
            "fullname": "MUMBAI CENTRAL",
            "code": "BCT"
        }
    ]
}

Purpose

Suggest full Station names using partial Station name.

Request URL

http://api.railwayapi.com/suggest_station/name/<partial station name>/apikey/<apikey>/

URL Parameters

Parameter Description
suggest_station Function name.
name Partial Station name.
apikey Your API Key.

Train Autocomplete Suggest

curl http://api.railwayapi.com/suggest_train/trains/shiv/apikey/myapikey/

JSON Response:

{
    "response_code": 200,
    "total": 4,
    "trains": [
        {
            "number": "12559",
            "name": "SHIV GANGA EXP"
        },
        {
            "number": "12560",
            "name": "SHIV GANGA EXP"
        },
        {
            "number": "52451",
            "name": "SHIVALK DLX EXP"
        },
        {
            "number": "52452",
            "name": "SHIVALK DLX EXP"
        }
    ]
}

Purpose

Suggest completed Train names or numbers given a partial Train name or number.

Request URL

http://api.railwayapi.com/suggest_train/trains/<partial train name or number>/apikey/<apikey>/

URL Parameters

Parameter Description
suggest_train Function name.
trains Partial Train name or number.
apikey Your API Key.

Response Codes

These are the common response_code from the API and their meanings.

Code Meaning
200 OK. Your request was successfully processed.
204 Empty response. Not able to fetch required data.
401 Authentication Error. You passed an unknown API Key.
403 Quota for the day exhausted. Applicable only for FREE users.
405 Account Expired. Renewal was not completed on time.