Developer GuidesBeginner
8 min read

Check Indian Railway PNR Status Programmatically

The definitive developer guide to querying live 10-digit PNR status, passenger manifests, berth allocations, and charting status with Node.js and Python.

IRCTC Developer Relations
IRCTC Developer Relations
Platform Engineering
Updated 2026-10-25
Prerequisites
  • •Basic familiarity with JavaScript/TypeScript or Python
  • •A valid 10-digit Indian Railways PNR number
  • •Free API key from https://irctc.dev/dashboard
Architecture Flow

Client application sends HTTP GET https://api.irctc.dev/api/v1/pnr/:pnr with x-api-key header ➔ Gateway queries central PRS reservation engine with zero browser overhead ➔ Returns normalized JSON passenger manifest with coach, berth, and chartStatus in under 100ms.

Implementation Steps

(5 Steps)
1

Anatomy of an Indian Railways PNR

A Passenger Name Record (PNR) is a unique 10-digit number generated by the PRS reservation system upon ticket booking. The first 3 digits indicate the PRS booking zone (e.g. 2 for Northern Railway, 8 for South Eastern), and the remaining 7 digits form the unique passenger record.

json
// Example: 2265248473
// Zone prefix: 226 (Northern Railway PRS)
// Serial: 5248473 (Unique Transaction Manifest)
Tip:Indian Railways purges PNR records approximately 5-9 days after train completion.
2

Check PNR in Node.js / TypeScript

Using the irctc-api npm package, checking a PNR requires just 3 lines of code with complete TypeScript types.

typescript
import { IrctcApi } from 'irctc-api';
const client = new IrctcApi({
apiKey: process.env.IRCTC_API_KEY || 'irctc_live_9a8f2c7e01d4'
});
async function verifyBooking(pnrNumber: string) {
try {
const pnr = await client.pnr.check(pnrNumber);
console.log(`Train: ${pnr.trainNumber} - ${pnr.trainName}`);
console.log(`From: ${pnr.from} -> To: ${pnr.to} | Date: ${pnr.doj}`);
console.log(`Chart Status: ${pnr.chartStatus}`);
pnr.passengers.forEach((p, idx) => {
console.log(`Passenger ${idx + 1}: ${p.currentStatus} | Coach: ${p.coach} | Seat: ${p.berthNumber} (${p.berth})`);
});
} catch (error: any) {
console.error('PNR verification error:', error.message);
}
}
verifyBooking('2265248473');
Tip:Notice the p.berth field: it returns clean, normalized berth types like "LOWER BERTH" or "MIDDLE BERTH" instead of ambiguous internal codes.
3

Check PNR in Python

In Python, you can use the standard requests library to call the gateway directly with standard JSON parsing.

python
import os
import requests
API_KEY = os.getenv("IRCTC_API_KEY", "irctc_live_9a8f2c7e01d4")
PNR = "2265248473"
url = f"https://api.irctc.dev/api/v1/pnr/{PNR}"
headers = {
"x-api-key": API_KEY,
"accept": "application/json",
"User-Agent": "pnr-verifier/v1.0"
}
response = requests.get(url, headers=headers, timeout=5.0)
if response.status_code == 200:
data = response.json().get("data", {})
print(f"Train: {data.get('trainNumber')} - {data.get('trainName')}")
print(f"Journey Date: {data.get('doj')} ({data.get('from')} -> {data.get('to')})")
print(f"Chart: {data.get('chartStatus')}")
for idx, p in enumerate(data.get("passengers", []), 1):
print(f" P{idx}: {p.get('currentStatus')} | Coach {p.get('coach', 'N.A')} / Seat {p.get('berthNumber', 'N.A')} [{p.get('berth', 'N.A')}]")
else:
print(f"Failed with HTTP {response.status_code}: {response.text}")
Tip:Python scripts can be easily integrated into Django, FastAPI, Flask, or AWS Lambda serverless functions.
4

Understanding Passenger Status Transitions

Indian Railways passengers transition across three primary booking states: CNF (Confirmed), RAC (Reservation Against Cancellation), and WL (Waitlist).

json
{
"bookingStatus": "WL 45",
"currentStatus": "CNF",
"coach": "B3",
"berthNumber": 24,
"berth": "LOWER BERTH"
}
Tip:When chartStatus changes to "CHART PREPARED", final coach and berth numbers are locked and cannot change.
5

Smart Polling vs Anti-Patterns

Do NOT poll PNR every 5 seconds. PNR status only changes upon cancellation or chart preparation (4 hours prior to departure). A smart backoff algorithm polls once daily until 24h before travel, then once every 30 minutes.

typescript
// Recommended Polling Schedule:
// • > 48h before departure: Poll once every 24 hours
// • 12h - 48h before departure: Poll every 4 hours
// • < 6h before departure: Poll every 15 minutes to catch Chart Preparation
Tip:Smart polling saves your API credits while ensuring passengers receive status updates the moment their ticket confirms.
Production Endpoint

Real-Time PNR Status API

Test live queries and inspect sub-100ms response payloads directly in the browser sandbox.

Frequently Asked Questions

Related Tutorials

View All Guides →