How to Get IRCTC PNR STATUS API to create pnr status checking website

How to Get IRCTC PNR STATUS API  to create pnr status checking website


This blog post is intended for websites and mobile developers who want to use Indian Railways train data and develop website or applications over it. It provides an introduction of how to use the API and reference material on the available parameters.


API Key

All eRail.in Indian Railways API applications should use an API key. Including a key in your request:


1. Allows you to monitor your application's API usage in the API console
2. Enables per-key instead of per-IP-address quota limits.
3. Ensures that eRail.in can contact you about your application if necessary.


The eRail.in Indian Railways API uses an API key to identify your application. API keys are managed through the eRail.in APIs console. To create your key:


1. Please send a request to Register
2. Upon approval you will be provided with the API key
3. Once the service has been activated, you can make HTTP request to the API.


To specify a key in your request, include it as the value of a key parameter.Usage Limits


1. Requests should be made from your server only and not from the clients browser or app.
2. API key is applicable for requests from one IP only
3. Developers should cache the data on their server, following limits apply while making requests between 00:00hr to 23:59 hrs IST
a. GetStations 10
b. GetTrains between unique pair of stations 4
4. Max 5 requests per second

Request Parameters

Certain parameters are required while others are optional. As is standard in URLs, all parameters are separated using the ampersand (&) character. The list of parameters and their possible values are enumerated below.


Required parameter

action — This represents what information is requested.
Optional parameters
stnfrom — Specifies the source station code.
stnto — Specifies the destination station code.
date — Specifies the date for which result is required. Date should be in format dd-MMM-yyyy (ex :05-SEP-2014).
class — Specifies the class code. (ex : SL / AC / 2S etc.)
trainno — Specifies the train number.
pnr — Specifies the pnr number.


Request Structure

Stations response is returned in the format indicated by the output flag within the URL request's path.
A sample HTTP request is shown below, getting list of stations:

http://api.erail.in/stations/?key=API_KEY

Response Structure

JSON Output

The JSON result is shown below.

    {
        "status" : "OK",
        "result" : [
                        {
                            "code" : "NDLS",
                            "name" : "New Delhi"
                        },
                        .....
                    ]
    }
    

Status Codes


The "status" field within the response object contains the status of the request, and may contain debugging information to help you track down why service failed. The "status" field may contain the following values:

OK indicates the response contains a valid result.
NOT_FOUND indicates request data not found.
ZERO_RESULTS indicates no result obtained from query.
INVALID_REQUEST indicates that the provided request was invalid. Common causes of this status include an invalid parameter or parameter value.
OVER_QUERY_LIMIT_FOR_DAYindicates that number of requests for a day exceeded permitted limit.
OVER_QUERY_LIMIT_FOR_QUERY indicates that number of requests for this query exceeded the permitted limit.
REQUEST_DENIED indicates that the service denied use of the api by your application.
UNKNOWN_ERROR indicates request could not be processed due to a server error. 

The request may succeed if you try again.

Error Messages


When the status code is other than OK, there may be an additional error_message field within the response object. This field contains more detailed information about the reasons behind the given status code.

Stations List

Get the result of all the stations with their station code, name, latitude and longitude.
http://api.erail.in/stations/?key=API_KEY

JSON Output

The JSON result is shown below.

    {
        "status" : "OK",
        "result" : [
                        { 
                            "code" : "NDLS",
                            "name" : "New Delhi"
                        },
                        { 
                            "code" : "BCT",
                            "name" : "Mumbai Central"
                        },
                        ....
                    ]
    }
    

Trains

Get trains between two given stations.

http://api.erail.in/trains/?key=API_KEY&stnfrom=NDLS&stnto=BCT&date=5-sep-2014&class=3A

Required parameter

stnfrom — Specifies the source station code.
stnto — Specifies the destination station code.

JSON Output

The JSON result is shown below.

    {
        "status" : "OK",
        "result" : [
                        { 
                            "trainno" : "12138",
                            "name" : "PUNJAB MAIL",
                            "class" : "1A,2A,3A,SL,GN",
                            "rundays" : "M,Tu,W,Th,F,Sa,Su",
                            "from" : "NDLS",
                            "fromname" : "New Delhi",
                            "dep" : "05.15",
                            "to" : "CSTM",
                            "toname" : "Mumbai CST",
                            "arr" : "07.35",
                            "pantry" : "Yes",
                            "type" : "Super Fast",
                            "datefrom" : "05-SEP-2014",
                            "dateto" : "06-SEP-2014",
                            "traveltime" : "1620"
                        },
                        ....
                    ]
    }
    

Route

Get route(s) of given train number. List of all available routes will be returned.

http://api.erail.in/route/?key=API_KEY&trainno=12138

Required parameter

trainno — Specifies the train number.

The JSON result is shown below.

    {
        "status" : "OK",
        "result" : { 
                     "trainno" : "17603",
                     "name" : "Kcg Ypr Exp",
                     "route" :
                        [
                            {
                                "cls" : "1A 2A 3A SL",
                                "stn" : 
                                    [
                                        {
                                            "code" : "KCG",
                                            "name" : "Kacheguda",
                                            "arr" : "First",
                                            "dep" : "21:00",
                                            "day" : 1,
                                            "remark" : ""
                                        },
                                        ....
                                    ]
                             },
                              ...
                          ]
                      }
    }
    
Full Route

Get full route of given train number. List of stations in route of train will be displayed, showing all passing stations also.

http://api.erail.in/fullroute/?key=API_KEY&trainno=12138

Required parameter

trainno — Specifies the train number.

The JSON result is shown below.

    {
        "status" : "OK",
        "result" : { 
                     "trainno" : "17603",
                     "route" :
                        [
                            {
                                   "code" : "KCG",
                                   "name" : "Kacheguda",
                                   "arr" : "First",
                                   "dep" : "21:00",
                                   "day" : 1,
                                   "stop" : "Y",
                                   "dts" : "2.5"
                             },
                              ...
                         ]
                    }
    }
    
Fare

Get fare for the journey from source station to destination station.

http://api.erail.in/fare/?key=API_KEY&trainno=12138&stnfrom=NDLS&stnto=CSTM&age=AD&quota=GN&class=1A&date=05-SEP-2014

Required parameter

trainno — Specifies the train number.
stnfrom — Specifies the source station code.
stnto — Specifies the destination station code.
age — Specifies the age code of passenger (CH - Child, AD - Adult, SM - Senior(Male), SF - Senior(Female)).
quota — Specifies the quota selected (ex : GN / CK etc.)
date — Specifies the date of run of train. Date should be in format dd-MMM-yyyy (ex :05-SEP-2014).
Optional parameter
class — Specifies the class selected (ex : SL / 1A etc.)

If class is not given, result contains fares for all classes otherwise for given class only.

http://api.erail.in/fare/?key=API_KEY&trainno=12138&stnfrom=NDLS&stnto=CSTM&age=AD&quota=GN&date=05-SEP-2014

The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "trainno" : "12952",
                        "type" : "RAJDHANI",
                        "from" : "NDLS",
                        "to" : "BCT",
                        "age" : "30",
                        "quota" : "GN",
                        "fare" : 
                                    [
                                        {
                                            "cls" : "1A",
                                            "fare" : "4680"
                                        },
                                        {
                                            "cls" : "2A",
                                            "fare" : "2810"
                                        },
                                        {
                                            "cls" : "3A",
                                            "fare" : "2030"
                                        }
                                    ]
                    }
    }

PNR Status

Get details of given PNR number.

http://api.erail.in/pnr?key=API_KEY&pnr=4857412584

Required parameter

pnr — Specifies the pnr number.

The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                      "pnr" : "6533543051",
                      "eticket" : true,
                      "journey" : "09-Sep-2014",
                      "trainno" : "12898",
                      "name" : "BBS PDY EXPRESS",
                      "from" : "VZM",
                      "to" : "MS",
                      "brdg" : "VZM",
                      "passengers" : 
                          [
                            {
                                "bookingstatus" : "RAC 14GNWL",
                                "currentstatus" : "B3 14",
                                "coach" : ""
                            },
                            ....
                         ],
                      "chart" : "CHART PREPARED",
                      "error" : ""
                  }
    }
    
Live Status

Get live running status of the given train.

http://api.erail.in/live/?key=API_KEY&trainno=12138&stnfrom=NDLS&date=05-SEP-2014

Required parameter

trainno — Specifies the train number.
stnfrom — Specifies the source station code.
date — Specifies the date for which result is required. Date should be in format dd-MMM-yyyy (ex :05-SEP-2014).
In Response, delaydep & delayarr are in minutes and depflag & arrflag = 0 (yet to arrive or depart) / 1 (arrived or departed)


The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "trainno" : "12138",
                        "name" : "PUNJAB MAIL",
                        "delayrun" : "Delayed by 26 Min.",
                        "alertmsg" : "NDLS",
                        "date" : "22-Sep-14",
                        "from" : "NDLS",
                        "fromname" : "NEW DELHI",
                        "scharr" : "22-Sep-14 04:50",
                        "schdep" : "22-Sep-14 05:15",
                        "actarr" : "22-Sep-14 04:50",
                        "actdep" : "22-Sep-14 05:20",
                        "delaydep" : 5,
                        "delayarr" : 5,
                        "platform" : 0,
                        "depflag" : 1,
                        "arrflag" : 1,
                        "gauge" : "",
                        "src" : "FZR",
                        "srcname" : "FIROZPUR CANT",
                        "dest" : "CSTM",
                        "destname" : "MUMBAI CST",
                        "statusat" : "23-Sep-14 08:29",
                        "statusmsg" : "",
                        "disttogo" : 1537
                    }
    }
    
Seat availability

Get seats availability in given train between given pair of stations in given quota, class and date.

http://api.erail.in/seats/?key=API_KEY&trainno=12138&stnfrom=NDLS&stnto=CSTM&quota=GN&class=SL&date=05-SEP-2014

Required parameter

trainno — Specifies the train number.
stnfrom — Specifies the source station code.
stnto — Specifies the destination station code.
quota — Specifies the quota selected (ex : GN / CK etc.)
class — Specifies the class selected (ex : SL / 1A etc.)
date — Specifies the date of run of train. Date should be in format dd-MMM-yyyy (ex :05-SEP-2014).

The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "trainno" : "12138",
                        "from" : "NDLS",
                        "to" : "BCT",
                        "cls" : "SL",
                        "quota" : "GN",
                        "error" : "",
                        "seats" : 
                                    [
                                        {
                                            "date" : "10-Sep-14",
                                            "seat" : "TRAIN DEPARTED"
                                        },
                                        {
                                            "date" : "11-Sep-14",
                                            "seat" : "GNWL91/WL22"
                                        },
                                        ....
                                    ]
                    }
    }

Coach Composition

Get coach Composition of a given train.

http://api.erail.in/coaches/?key=API_KEY&trainno=12138

Required parameter

trainno — Specifies the train number.
The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "trainno" : "12138",
                        "coaches" : 
                                    [
                                        {
                                            "prsid" : "",
                                            "cls" : "En"
                                        },
                                        {
                                            "prsid" : "H1",
                                            "cls" : "1A"
                                        },
                                        ....
                                    ]
                    }
    }

Cancelled Trains

Get list of all cancelled trains.

http://api.erail.in/cancelled/?key=API_KEY&date=TD

Required parameter

date — Specifies the selected date. 
Valid values : TD - Today, YS - Yesterday, TM - Tomorrow

fromstn and tostn are present for partially cancelled trains, while are blank for fully cancelled trains.

The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "date" : "22-Sep-2014",
                        "trains" : 
                                    [
                                        {
                                            "trainno":"53231",
                                            "startdate":"22 Sep 2014",
                                            "trainname":"TIA-DNR PASSENGER",
                                            "trainsrc":"TIA",
                                            "traindstn":"DNR",
                                            "fromstn":"TIA",  
                                            "tostn":"RGD",
                                            "traintype":"PASSENGER"
                                        },
                                        {
                                            "trainno":"05725",
                                            "startdate":"22 Sep 2014",
                                            "trainname":"NJP-NCB SPECIAL",
                                            "trainsrc":"NJP",
                                            "traindstn":"NCB",
                                            "traintype":"SPECIAL",
                                            "fromstn":"", 
                                            "tostn":""
                                        },
                                        ....
                                    ]
                    }
    }

Diverted Trains

Get list of all diverted trains.

http://api.erail.in/diverted/?key=API_KEY&date=TD

Required parameter

date — Specifies the selected date. Valid values : TD - Today, YS - Yesterday, TM - Tomorrow

The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "date" : "22-Sep-2014",
                        "trains" : 
                                    [
                                        {
                                            "from" : "KOAA",
                                            "fromname" : "KOLKATA",
                                            "dep" : "12:55",
                                            "to" : "BLGT",
                                            "toname" : "BALURGHAT",
                                            "trainno" : "13161",
                                            "trainname" : "KOLKATA-BALURGHAT EXPRES",
                                            "journey" : "22-Sep-2014",
                                            "cancelfrom" : "KOAA",
                                            "cancelfromname" : "KOLKATA",
                                            "cancelto" : "NFK",
                                            "canceltoname" : "NEW FARAKKA JN"
                                        },
                                        ....
                                    ]
                    }
    }

Rescheduled Trains

Get list of all re-scheduled trains.

http://api.erail.in/rescheduled/?key=API_KEY&date=TD

Required parameter

date — Specifies the selected date. Valid values : TD - Today, YS - Yesterday, TM - Tomorrow

The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "date" : "22-Sep-2014",
                        "trains" : 
                                    [
                                        {
                                            "from" : "JHS",
                                            "fromname" : "JHANSI JN",
                                            "dep" : "16:50",
                                            "to" : "BDTS",
                                            "toname" : "BANDRA TERMINUS",
                                            "trainno" : "11103",
                                            "trainname" : "JHS-BDTS",
                                            "journey" : "22-Sep 16:50",
                                            "rescheduleddate" : "22-Sep 17:25",
                                            "rescheduledtime" : "00:35"
                                        },
                                        ....
                                    ]
                    }
    }

Trains At Station

Get list of trains at given station withing in given hours.

http://api.erail.in/trainsatstation/?key=API_KEY&stnfrom=NDLS&stnto=BCT&hr=10

Required parameter

stnfrom — Specifies the source station code.
hr — Specifies the hours from current time to search train.
Optional parameter
stnto — Specifies the destination station code.
If stnto is not given then all trains starting from stnfrom are displayed.


The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "fromstn" : "NDLS",
                        "tostn" : "BCT",
                        "hr" : "10",
                        "trains" : 
                                    [
                                        {
                                            "from" : "FZR",
                                            "fromname" : "FIROZPUR CANT",
                                            "schdep" : "13:30",
                                            "actdep" : "13:30",
                                            "delaydep" : "RT",
                                            "to" : "BCT",
                                            "toname" : "MUMBAI CENTRAL",
                                            "scharr" : "12:55",
                                            "actarr" : "12:55",
                                            "delayarr" : "RT",
                                            "trainno" : "19024",
                                            "trainname" : "FZR BCT JANATA EXPRESS",
                                            "type" : "MEX",
                                            "platform" : "6"
                                        },
                                        ....
                                    ]
                    }
    }

Rakes of Train

Get list of all rakes of a given train.

http://api.erail.in/rakes/?key=API_KEY&trainno=22905

Required parameter

trainno — Specifies the train number.

The JSON result is shown below.

    {
        "status" : "OK",
        "result" :  { 
                        "trainno" : "22905",
                        "rakes" : 
                                 {
                                    "totalrakes" : 3,
                                    "maintrains" : [12905,12906,19201,19202,19263,19264,19269,19270],
                                    "sliptrains" : [22905,22906]
                                 }
                    }
    }

Appendix

Classes

List of all classes available .

1A — First AC
2A — 2 Tier AC
3A — 3 Tier AC
CC — Chair Car
FC — First Class
SL — Sleeper
2S — 2nd Sitting
3E — 3 Tier Economy
GN — General

Quotas

List of all quotas available .

CK — Tatkal Quota
LD — Ladies Quota
DF — Defence Quota
FT — Foreign Tourist
DP — Duty Pass Quota
HP — Handicapped Quota
PH — Parliament House Quota
SS — Lower Berth Quota
YU — Yuva Quota
GN — General Quota

Train Type

List of all train types.

PAS — Passenger Trains
DRNT — Duronto
CK — Special
MEX — Mail/Express
SUF — Superfast
LUX — Luxury Trains
RAJ — Rajdhani
SHT — Shatabdi
JSH — Janshatabdi
GBR — Garibrath/Yuva

how irctcpnr status checking websites working ? 

1 comments:

Erail Registration doesn't work, it's been months and i didn't got any reply or api key.


EmoticonEmoticon