NAV Navbar
Logo
shell

Introduction

Welcome to RailwayAPI Documentation. Our API is organized around GET Requests. You can use our API to get information for Indian Railways regarding Live Train Status, PNR Status, Train Schedule, Station Details and other things.

Authentication

You must have an API key to use the API functions. Complete the registration to get your API key.

Your API key must be included in all the requests.

API Functions

Live Train Status

Purpose

Get Live running status of Train.

Request URL

http://api.railwayapi.com/v2/live/train/<train number>/date/<dd-mm-yyyy>/apikey/<apikey>/

URL Parameters

Parameter Description
live Function name.
train The train number.
date Train start date in dd-mm-yyyy format.
apikey Your API key.
curl "http://api.railwayapi.com/v2/live/train/12046/date/20-06-2017/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit": 3,
  "position": "Train has reached Destination and late by 5 minutes",
  "train": {
    "number": "12046",
    "name": "CDG NDLS SHTBDI"
  },
  "route": [
    {
      "no": 1,
      "day": 0,
      "station": {
        "name": "CHANDIGARH",
        "code": "CDG"
      },
      "has_arrived": false,
      "has_departed": true,
      "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,
      "day": 0,
      "station": {
        "name": "AMBALA CANT JN",
        "code": "UMB"
      },
      "has_arrived": true,
      "has_departed": true,
      "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,
      "day": 0,
      "station": {
        "name": "NEW DELHI",
        "code": "NDLS"
      },
      "has_arrived": true,
      "has_departed": false,
      "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
    }
  ]
}

PNR Status

Purpose

Get PNR status details.

Request URL

http://api.railwayapi.com/v2/pnr-status/pnr/<pnr no>/apikey/<apikey>/

URL Parameters

Parameter Description
pnr-status Function name.
pnr PNR number to query.
apikey Your API key.
curl "http://api.railwayapi.com/v2/pnr-status/pnr/1234567890/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit": 3,
  "pnr": "1234567890",
  "doj": "25-6-2017",
  "total_passengers": 3,
  "chart_prepared": true,
  "from_station": {
    "name": "Kopargaon",
    "code": "KPG"
  },
  "to_station": {
    "name": "Hazrat Nizamuddin",
    "code": "NZM"
  },
  "boarding_point": {
    "name": "Kopargaon",
    "code": "KPG"
  },
  "reservation_upto": {
    "name": "Hazrat Nizamuddin",
    "code": "NZM"
  },
  "train": {
    "name": "GOA EXPRESS",
    "number": "12779"
  },
  "journey_class": {
    "name": "SLEEPER CLASS",
    "code": "SL"
  },
  "passengers": [
    {
      "no": 1,
      "coach_position": 0,
      "current_status": "RLWL/11",
      "booking_status": "RLWL/39/GN"
    },
    {
      "no": 2,
      "coach_position": 0,
      "current_status": "RLWL/12",
      "booking_status": "RLWL/40/GN"
    },
    {
      "no": 3,
      "coach_position": 0,
      "current_status": "RLWL/13",
      "booking_status": "RLWL/41/GN"
    }
  ]
}

Train Route

Purpose

Get details about all the stations in the train’s route.

Request URL

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

URL Parameters

Parameter Description
route Function name.
train The train number to query.
apikey Your API key.
curl "http://api.railwayapi.com/v2/route/train/12006/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit": 1,
  "train": {
    "name": "KLK-NDLS SHATABDI EXP",
    "number": "12006",
    "days": [
      {
        "code": "MON",
        "runs": "Y"
      },
      {
        "code": "TUE",
        "runs": "Y"
      },
      {
        "code": "WED",
        "runs": "Y"
      },
      {
        "code": "THU",
        "runs": "Y"
      },
      {
        "code": "FRI",
        "runs": "Y"
      },
      {
        "code": "SAT",
        "runs": "Y"
      },
      {
        "code": "SUN",
        "runs": "Y"
      }
    ],
    "classes": [
      {
        "code": "3A",
        "available": "N"
      },
      {
        "code": "SL",
        "available": "N"
      },
      {
        "code": "1A",
        "available": "N"
      },
      {
        "code": "2S",
        "available": "N"
      },
      {
        "code": "FC",
        "available": "N"
      },
      {
        "code": "2A",
        "available": "N"
      },
      {
        "code": "CC",
        "available": "N"
      },
      {
        "code": "3E",
        "available": "N"
      }
    ]
  },

  "route": [
    {
      "no": 1,
      "scharr": "SOURCE",
      "schdep": "06:15",
      "distance": 0,
      "halt": -1,
      "day": 1,
      "station": {
        "name": "KALKA",
        "code": "KLK",
        "lng": null,
        "lat": null
      }
    },
    {
      "no": 2,
      "scharr": "06:45",
      "schdep": "06:53",
      "distance": 37,
      "halt": 8,
      "day": 1,
      "station": {
        "name": "CHANDIGARH",
        "code": "CDG",
        "lng": null,
        "lat": null
      }
    },
    {
      "no": 3,
      "scharr": "07:33",
      "schdep": "07:38",
      "distance": 104,
      "halt": 5,
      "day": 1,
      "station": {
        "name": "AMBALA CANT JN",
        "code": "UMB",
        "lng": null,
        "lat": null
      }
    },
    {
      "no": 4,
      "scharr": "08:10",
      "schdep": "08:12",
      "distance": 146,
      "halt": 2,
      "day": 1,
      "station": {
        "name": "KURUKSHETRA JN",
        "code": "KKDE",
        "lng": null,
        "lat": null
      }
    },
    {
      "no": 5,
      "scharr": "10:20",
      "schdep": "DEST",
      "distance": 302,
      "halt": -1,
      "day": 1,
      "station": {
        "name": "NEW DELHI",
        "code": "NDLS",
        "lng": null,
        "lat": null
      }
    }
  ]
}

Seat availability

Purpose

Get train seat availability.

Request URL

http://api.railwayapi.com/v2/check-seat/train/<train number>/source/<stn code>/dest/<dest code>/date/<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.
curl "http://api.railwayapi.com/v2/check-seat/train/12001/source/BPL/dest/NDLS/date/16-07-2017/class/CC/quota/GN/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit": 3,
  "train": {
    "name": "NDLS SHATABDI E",
    "number": "12001"
  },
  "from_station": {
    "lat": 23.2599333,
    "name": "BHOPAL  JN",
    "lng": 77.412615,
    "code": "BPL"
  },
  "to_station": {
    "lat": 30.6016778,
    "name": "NEW DELHI",
    "lng": -98.3488272,
    "code": "NDLS"
  },
  "journey_class": {
    "name": "AC CHAIR CAR",
    "code": "CC"
  },
  "quota": {
    "name": "GENERAL QUOTA",
    "code": "GN"
  },
  "availability": [
    {
      "date": "14-07-2017",
      "status": "AVAILABLE 364"
    },
    {
      "date": "15-07-2017",
      "status": "AVAILABLE 361"
    },
    {
      "date": "16-07-2017",
      "status": "AVAILABLE 284"
    },
    {
      "date": "17-07-2017",
      "status": "AVAILABLE 351"
    },
    {
      "date": "18-07-2017",
      "status": "AVAILABLE 303"
    },
    {
      "date": "19-07-2017",
      "status": "AVAILABLE 329"
    }
  ]
}

Train Between Stations

Purpose

Get trains running between stations.

Request URL

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

URL Parameters

Parameter Description
between Function name.
source Source station code.
dest Destination station code.
date Journey date in DD-MM-YYYY format.
apikey Your API key.
curl "http://api.railwayapi.com/v2/between/source/gkp/dest/jat/date/24-06-2017/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "total": 1,
  "debit": 1,
  "trains": [
    {
      "number": "12491",
      "name": "MOURDHWAJ EXPRESS",
      "travel_time": "21:45",
      "src_departure_time": "14:05",
      "dest_arrival_time": "11:50",
      "from_station": {
        "code": "GKP",
        "name": "GORAKHPUR"
      },
      "to_station": {
        "code": "JAT",
        "name": "JAMMU TAWI"
      },
      "classes": [
        {
          "code": "2S",
          "available": "N",
          "name": "SECOND SEATING"
        },
        {
          "code": "CC",
          "available": "N",
          "name": "AC CHAIR CAR"
        },
        {
          "code": "FC",
          "available": "N",
          "name": "FIRST CLASS"
        },
        {
          "code": "SL",
          "available": "Y",
          "name": "SLEEPER CLASS"
        },
        {
          "code": "2A",
          "available": "Y",
          "name": "SECOND AC"
        },
        {
          "code": "1A",
          "available": "Y",
          "name": "FIRST AC"
        },
        {
          "code": "3E",
          "available": "N",
          "name": "3rd AC ECONOMY"
        },
        {
          "code": "3A",
          "available": "Y",
          "name": "THIRD AC"
        }
      ],
      "days": [
        {
          "code": "MON",
          "runs": "N"
        },
        {
          "code": "TUE",
          "runs": "N"
        },
        {
          "code": "WED",
          "runs": "N"
        },
        {
          "code": "THU",
          "runs": "N"
        },
        {
          "code": "FRI",
          "runs": "N"
        },
        {
          "code": "SAT",
          "runs": "N"
        },
        {
          "code": "SUN",
          "runs": "Y"
        }
      ]
    }
  ]
}

Train Name/Number

Purpose

Get train name using number and vice versa.

Request URL

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

URL Parameters

Parameter Description
name-number Function name.
train Train name or number.
apikey Your API key.
curl "http://api.railwayapi.com/v2/name-number/train/bhopal/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit" : 1,
  "train": {
    "number": "12155",
    "name": "BHOPAL EXPRESS",
    "days": [
      {
        "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"
      },
      {
        "day-code": "SUN",
        "runs": "Y"
      }
    ]
  }
}

Train Fare Enquiry

Purpose

Get fares of train.

Request URL

http://api.railwayapi.com/v2/fare/train/<train number>/source/<source stn code>/dest/<dest stn code>/age/<age>/quota/<quota>/date/<dd-mm-yyyy>/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.
date Journey date in DD-MM-YYYY format.
apikey Your API key.
curl "http://api.railwayapi.com/v2/fare/train/12555/source/gkp/dest/ndls/age/18/quota/PT/date/23-11-2014/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit": 1,
  "train": {
    "number": "12555",
    "name": "GORAKDAM EXPRES"
  },
  "from_station": {
    "code": "GKP",
    "name": "GORAKHPUR JN"
  },
  "to_station": {
    "code": "NDLS",
    "name": "NEW DELHI"
  },
  "quota": {
    "code": "PT",
    "name": "Premium Tatkal Quota"
  },
  "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"
    }
  ]
}

Train Arrivals

Purpose

Get list of trains arriving at a station within a window period along with their live status.

Request URL

http://api.railwayapi.com/v2/arrivals/station/<stn code>/hours/<window period in hours>/apikey/<apikey>/

URL Parameters

Parameter Description
arrivals Function name.
station Station code.
hours Window time in hours to search, valid values are 2 or 4.
apikey Your API key.
curl "http://api.railwayapi.com/v2/arrivals/station/cdg/hours/2/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit" : 1,
  "trains": [
    {
      "train": {
        "number": "04921",
        "name": "SRE-UMB MEMU SPECIAL",
        "start_time": "04:45",
        "type": "HSP"
      },
      "source": {
        "code": "SRE",
        "name": "SAHARANPUR"
      },
      "dest": {
        "code": "UMB",
        "name": "AMBALA CANT JN"
      }
    },
    {
      "train": {
        "number": "04922",
        "name": "UMB-SRE MEMU SPECIAL",
        "start_time": "20:45",
        "type": "HSP"
      },
      "source": {
        "code": "UMB",
        "name": "AMBALA CANT JN"
      },
      "dest": {
        "code": "SRE",
        "name": "SAHARANPUR"
      }
    }
  ]
}

Cancelled Trains

Purpose

Get list of all cancelled trains on a particular day.

Request URL

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

URL Parameters

Parameter Description
cancelled Function name.
date Date in DD-MM-YYYY format.
apikey Your API key.
curl "http://api.railwayapi.com/v2/cancelled/date/26-12-2015/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit": 1,
  "trains": [
    {
      "name": "ANVT-UHP EXPRESS SPL",
      "number": "04401",
      "type": "HSP",
      "start_time": "22:20",
      "source": {
        "name": "ANAND VIHAR TERMINAL",
        "code": "ANVT"
      },
      "dest": {
        "name": "SH MATA V DEVI KATRA",
        "code": "SVDK"
      }
    },
    {
      "name": "LTT - HW SUPER FAST EXP",
      "number": "12171",
      "type": "SUF",
      "start_time": "07:55",
      "source": {
        "name": "LOKMANYATILAK",
        "code": "LTT"
      },
      "dest": {
        "name": "HARIDWAR JN",
        "code": "HW"
      }
    }
  ]
}

Rescheduled Trains

Purpose

Get list of all rescheduled trains on a particular date.

Request URL

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

URL Parameters

Parameter Description
rescheduled Function name.
date Date in DD-MM-YYYY format.
apikey Your API key.
curl "http://api.railwayapi.com/v2/rescheduled/date/25-06-2017/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit": 1,
  "trains": [
    {
      "name": "ADI -HOWRAH EXPRESS",
      "number": "12833",
      "rescheduled_time": "03:15",
      "rescheduled_date": "03-7-2017",
      "time_diff": "03:00",
      "from_station": {
        "code": "ADI",
        "name": "AHMEDABAD JN"
      },
      "to_station": {
        "code": "HWH",
        "name": "HOWRAH JN"
      }
    }
  ]
}

Station Name to Code

Purpose

Get station details of the given station and its nearby stations using partial station name. Station’s name is autocompleted.

Request URL

http://api.railwayapi.com/v2/name-to-code/station/<stn name>/apikey/<apikey>/

URL Parameters

Parameter Description
name-to-code Function name.
station Station name.
apikey Your API key.
curl "http://api.railwayapi.com/v2/name-to-code/name/gkp/apikey/myapikey/"

JSON Response:

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

Station Code to Name

Purpose

Get station details of the given station along with its nearby stations using its station code.

Request URL

http://api.railwayapi.com/v2/code-to-name/code/<stn code>/apikey/<apikey>/

URL Parameters

Parameter Description
code-to-name Function name.
code Station code.
apikey Your API key.
curl "http://api.railwayapi.com/v2/code-to-name/code/gkp/apikey/myapikey/"

JSON Response:

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

Station Autocomplete Suggest

Purpose

Suggest full station names given a partial station name.

Request URL

http://api.railwayapi.com/v2/suggest-station/name/<partial stn name>/apikey/<apikey>/

URL Parameters

Parameter Description
suggest-station Function name.
name Partial station name.
apikey Your API key.
curl "http://api.railwayapi.com/v2/suggest-station/name/mum/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit" : 1,
  "total": 2,
  "stations": [
    {
      "name": "MUMBAI CST",
      "code": "CSTM"
    },
    {
      "name": "MUMBAI CENTRAL",
      "code": "BCT"
    }
  ]
}

Train Autocomplete Suggest

Purpose

Suggest full train names or numbers given a partial train name or number.

Request URL

http://api.railwayapi.com/v2/suggest-train/train/<partial train name or number>/apikey/<apikey>/

URL Parameters

Parameter Description
suggest-train Function name.
train Partial train name or number.
apikey Your API key.
curl "http://api.railwayapi.com/v2/suggest-train/train/shiv/apikey/myapikey/"

JSON Response:

{
  "response_code": 200,
  "debit": 1,
  "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"
    }
  ]
}

Credits and Debits

Each RailwayAPI user gets credits depending on their plan. Credits are used from your balance whenever an API call is made. Each API function has a value attached to it, which is subtracted from the user’s total credit balance whenever they make an API call. The debit key is included in each API response and it contains the value by which the user’s credit was debited. Whether the user will be debited or not depends upon the response_code. We debit the users credit balance if they made a valid API call(no argument or type errors). Sometimes, the user may not get the data they requested like in the case of PNR service being down. But we will still have to debit from the balance because we had to use computational resources on our servers.

Here is a list detailing the credits debited on each API function.

Function Debit
code-to-name 1
name-to-code 1
route 1
name-number 1
suggest-station 1
suggest-train 1
check-seat 3
live 2
fare 1
between 1
pnr-status 3
arrivals 1
cancelled 1
rescheduled 1

Response Codes

The response_code key included in each response contains the status of the result returned.

Codes and their meanings:

Code Description
200 Success.
210 Train doesn’t run on the date queried.
211 Train doesn’t have journey class queried.
220 Flushed PNR.
221 Invalid PNR.
304 Data couldn’t be fetched. No Data available.
404 Data couldn’t be fetched. Request couldn’t go through.
504 Argument error.
704 Unauthorized user query. User account expired/exhausted or unregistered.