Get setup
Introducing the new IRCTC Connect documentation
Find all the guides and resources you need to develop with IRCTC Connect. An API key is required — call configure(apiKey) once at startup and all functions will automatically authenticate with the backend.
Quickstarts
Explore our end-to-end tutorials and get started.
Core Features
Pre-built components and APIs for PNR and Trains.
Reliability
Input validations and strict error handling guidelines.
API Reference
Dig into our API reference documentation and SDKs.
Explore by frontend framework
Find all the guides and resources you need to develop with IRCTC Connect.
Next.js
Easily add fast train scheduling and PNR tracking to Next.js.
React
Get started installing and initializing IRCTC Connect in a React App.
Express
Learn about installing and initializing APIs in an Express server.
Vanilla Node
Use IRCTC Connect cleanly with pure Javascript to query data.
Installation
npm install irctc-connectRequirements
- ✓ Node.js 14+
- ✓ Internet connection
- ✓ Valid API key added in `.env` (for example `IRCTC_API_KEY`)
Supported Platforms
- → Node.js apps
- → Express.js servers
- → Next.js applications
- → React Native
Quick Start
configure(apiKey) once before using any other function — store your key safely in environment variables.import {
configure,
checkPNRStatus, getTrainInfo, trackTrain,
liveAtStation, searchTrainBetweenStations, getAvailability
} from 'irctc-connect';
// Step 1: configure once with your API key (store it in .env)
// .env → IRCTC_API_KEY=your_api_key_here
configure(process.env.IRCTC_API_KEY);
// Check PNR status
const pnrResult = await checkPNRStatus('1234567890');
// Get train information
const trainResult = await getTrainInfo('12345');
// Track live train status
const trackResult = await trackTrain('12345', '06-12-2025');
// Get live trains at station
const stationResult = await liveAtStation('NDLS');
// Search trains between stations
const searchResult = await searchTrainBetweenStations('NDLS', 'BCT');
// Get seat availability with fare
const availResult = await getAvailability('12496', 'ASN', 'DDU', '27-12-2025', '2A', 'GN');checkPNRStatus(pnr)
Get comprehensive PNR status with passenger details and journey information.
Parameters
pnr(string) — 10-digit PNR numberconst result = await checkPNRStatus('1234567890');
if (result.success) {
console.log('PNR:', result.data.pnr);
console.log('Status:', result.data.status);
console.log('Train:', result.data.train.name);
console.log('Journey:', result.data.journey.from.name, '→', result.data.journey.to.name);
result.data.passengers.forEach(passenger => {
console.log(`${passenger.name}: ${passenger.status} - ${passenger.seat}`);
});
}{
success: true,
data: {
pnr: "1234567890",
status: "CNF",
train: { number: "12345", name: "Rajdhani Express", class: "3A" },
journey: {
from: { name: "New Delhi", code: "NDLS", platform: "16" },
to: { name: "Mumbai Central", code: "BCT", platform: "3" },
departure: "20:05",
arrival: "08:35",
duration: "12h 30m"
},
passengers: [
{ name: "JOHN DOE", status: "CNF", seat: "B1-45", berthType: "SL" }
]
}
}getTrainInfo(trainNumber)
Get detailed train information including complete route with station coordinates.
Parameters
trainNumber(string) — 5-digit train numberconst result = await getTrainInfo('12345');
if (result.success) {
const { trainInfo, route } = result.data;
console.log(`🚂 ${trainInfo.train_name} (${trainInfo.train_no})`);
console.log(`📍 ${trainInfo.from_stn_name} → ${trainInfo.to_stn_name}`);
console.log(`⏱️ ${trainInfo.from_time} - ${trainInfo.to_time}`);
console.log(`📅 Running Days: ${trainInfo.running_days}`);
route.forEach(station => {
console.log(` ${station.stnName} - ${station.departure}`);
});
}trackTrain(trainNumber, date)
Get real-time train status and tracking for a specific date with detailed station-wise information including delays and coach positions.
Parameters
trainNumber(string) — 5-digit train numberdate(string) — Date in dd-mm-yyyy formatconst result = await trackTrain('12342', '06-12-2025');
if (result.success) {
const { trainNo, trainName, statusNote, stations } = result.data;
console.log(`🚂 ${trainName} (${trainNo})`);
console.log(`📍 Status: ${statusNote}`);
stations.forEach(station => {
console.log(`🚉 ${station.stationName} (${station.stationCode})`);
console.log(` Arrival: ${station.arrival.scheduled} → ${station.arrival.actual}`);
if (station.arrival.delay) {
console.log(` ⚠️ Delay: ${station.arrival.delay}`);
}
});
}liveAtStation(stnCode)
Get list of upcoming trains at any station with real-time information.
Parameters
stnCode(string) — Station code (e.g., 'NDLS', 'BCT', 'HWH')const result = await liveAtStation('NDLS');
if (result.success) {
result.data.forEach(train => {
console.log(`🚂 ${train.trainno} - ${train.trainname}`);
console.log(` 📍 ${train.source} → ${train.dest}`);
console.log(` ⏰ Time: ${train.timeat}`);
});
}searchTrainBetweenStations(from, to)
Find all trains running between two stations with timing and availability.
Parameters
fromStationCode(string) — Origin station codetoStationCode(string) — Destination station codeconst result = await searchTrainBetweenStations('NDLS', 'BCT');
if (result.success) {
result.data.forEach(train => {
console.log(`🚂 ${train.train_name} (${train.train_no})`);
console.log(` 📍 ${train.from_stn_name} → ${train.to_stn_name}`);
console.log(` ⏰ ${train.from_time} → ${train.to_time}`);
console.log(` ⏱️ Duration: ${train.travel_time}`);
console.log(` 📏 Distance: ${train.distance} km`);
console.log(` 📅 Days: ${train.running_days}`);
});
}getAvailability( trainNo, fromStnCode, toStnCode, date, coach, quota )
Check seat availability with complete fare breakdown for a specific train journey.
Parameters
trainNo(string) — 5-digit train numberfromStnCode(string) — Origin station code (e.g. ASN, NDLS)toStnCode(string) — Destination station code (e.g. DDU, BCT)date(string) — Journey date in DD-MM-YYYY formatcoach(string) — Class: 2S, SL, 3A, 3E, 2A, 1A, CC, ECquota(string) — Quota: GN, LD, SS, TQconst result = await getAvailability(
'12496',
'ASN',
'DDU',
'27-12-2025',
'2A',
'GN'
);
if (result.success) {
const { train, fare, availability } = result.data;
console.log(`🚂 ${train.trainName} (${train.trainNo})`);
console.log(
`📍 ${train.fromStationName} → ${train.toStationName}`
);
console.log('\n💰 Fare Breakdown:');
console.log('Base Fare:', fare.baseFare);
console.log('Reservation:', fare.reservationCharge);
console.log('Superfast:', fare.superfastCharge);
console.log('Total:', fare.totalFare);
console.log('\n📅 Availability:');
availability.forEach(day => {
console.log(
`${day.date}: ${day.availabilityText} (${day.prediction})`
);
});
}Live Playground
Test the API functions with your own data. See live JSON response, status code, and response time. Get your API key by signing in.
Input Validation
PNR Number
- • Must be exactly 10 digits
- • Only numeric characters
- • Auto-cleans non-numeric input
Train Number
- • Must be exactly 5 characters
- • Valid train number string
Date Format
- • Format: dd-mm-yyyy
- • Validates actual dates
- • No invalid dates like 32-01-2025
Station Codes
- • Valid station code strings
- • Examples: NDLS, BCT, HWH
Status Codes
| Code | Description |
|---|---|
CNF | Seat is confirmed |
WL | Not confirmed yet |
RAC | Partially confirmed |
CAN | Ticket cancelled |
PQWL | On pooled quota |
TQWL | On tatkal quota |
GNWL | On general quota |
Error Handling
All functions return a consistent response structure. Always check the success field before accessing data.
✅ Success Response
{
success: true,
data: { ... }
}❌ Error Response
{
success: false,
error: "Error message"
}Common Error Scenarios
- • Missing API key —
configure(apiKey)not called - • Invalid or expired API key (401 Unauthorized)
- • API key inactive (403 Forbidden)
- • Monthly usage limit exceeded (429 Too Many Requests)
- • Invalid input parameters
- • Network timeouts (10-second timeout)
- • API service unavailable
- • Invalid PNR/train numbers
- • Invalid date formats