Railway PNR Status API

It may seem frustrating to know, but there is no official API of the railway PNR status. If you are searching of an API, you won’t be getting success. This is totally waste of time, like to throw the stone in the air.

However their are some languages that can fetch the data from the opened page in the browser. I’m talking about the reading data of an internet page programmatically, which can be used for fetching the data from Indian railway website. Some of these languages are as follows:


Let’s get started with PHP cURL, which is a well known source for reading the data from an Internet page.

When you search Your PNR status through Indian Railway website, You may have seen a captcha for preventing the spammers. You just need to bypass this captcha and hit that page programmatically, which will open the current status and you can read that all result data with php cURL.

Here is the example that can be used to bypass the captcha

$url_captch = 'http://www.indianrail.gov.in/pnr_Enq.html';
$url_pnr = 'http://www.indianrail.gov.in/cgi_bin/inet_pnstat_cgi_10521.cgi';
// Submit the captcha and PNR

$post_data['lccp_cap_val'] = 12345; //dummy captcha
$post_data['lccp_capinp_val'] = 12345;

$post_data['submit'] = "Get Status";
$post_string = createPostString($post_data);

$result = makeWebCall($url_pnr,$post_string,$url_captch );

By this process you enter the dummy captcha and hit the button through your programme, once the result is displayed the given url, you store the all result data on an array can read that all data from your programme.

If you need this working code you can write to us at info@html5andcss3.org

If you have any question regarding this script, you can reach us via inserting a comment in the comment box.