API Documentation for PNR Prediction

What is PNR Prediction Utility

PNR Prediction utility lets you predict the PNR status of your ticket. It can predict the chances of getting a confirmed ticket for your waitlisted ticket.

In order to use this Predict PNR status API, you need the API Keys.

How do I get API Keys

To acess the API key, you must register. Click to register. After successful registration, you will get access to the help desk area of Ayansh TechoSoft.

By default, everyone has access to the Demo API Key. You can use this demo API key only for development purpose. You cannot use this in production environment.

Go to the Payments page and purchase the service. After successful payment, you will get access to the real API key for production use. In case the payment is done and API key is not recived, please contact the help desk

How to call the API

This is a REST API. You call it like you would call any other REST API.

The important parameters are:

  1. PNR Number : The 10 digit PNR Number.
  2. Train Number : A valid train number
  3. Travel Date: The date of travel
  4. Travel Class: The class of travel. Note, we support only 3A and SL class
  5. From Station: The origin station code
  6. To Station: The destination station code
  7. Current Status: Current availability status

You must either provide the PNR Number or the rest of the parameters.

Note: If you provide the PNR number, we can get all details. However, for better performance, it is recommended that you provide all the parameters.

Result of API

The API returns the data in the json format. Example json is shown

		"ResultCode": "0",
		"CNFProbability": "70",
		"RACProbability": 80"",
		"OptimisticCNFProbability": "78",
		"OptimisticRACProbability": "85",
		"ExpectedStatus": "WL2",
		"Message": "Probability Calculated Successfully"

Result Codes

The result codees will help you analyze the bug

  • 0 : Calculation is success
  • 420 : Incomplete input / invalid request
  • 999 : Limit exceeded

Android Example

The below code shows an example how to call this API from Java Class

// API Service URL.
String url = "http://ayansh.com/pnr-prediction/predict-pnr.php";
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);

// Prepare Input Data
List nameValuePairs = new ArrayList(2);

nameValuePairs.add(new BasicNameValuePair("client_id", "1"));
nameValuePairs.add(new BasicNameValuePair("app_id", "1"));
nameValuePairs.add(new BasicNameValuePair("api_key", "dsk0sdbt9j3kf"));

nameValuePairs.add(new BasicNameValuePair("pnr_no", ""));
nameValuePairs.add(new BasicNameValuePair("train_no", "12627"));
nameValuePairs.add(new BasicNameValuePair("travel_date", "27-03-2014"));
nameValuePairs.add(new BasicNameValuePair("travel_class", "3A"));
nameValuePairs.add(new BasicNameValuePair("from_station", "SBC"));
nameValuePairs.add(new BasicNameValuePair("to_station", "NDLS"));
nameValuePairs.add(new BasicNameValuePair("current_status", "GNWL30/WL8"));

// Set Input to HTTP Post
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);

// Open Stream for Reading.
InputStream is = response.getEntity().getContent();

// Get Input Stream Reader.
InputStreamReader isr = new InputStreamReader(is);

// Read the output to a string.
BufferedReader reader = new BufferedReader(isr);

StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {

// Get JSON From Output String.
JSONObject output = new JSONObject(builder.toString());

// Extract result data from output.
int resultCode = output.getInt("ResultCode");
float cnfProb = output.getInt("CNFProbability");

Got a bug

In case you find a bug, please report it to the developer