IRCTC Connect Logo
Irctc-connect

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.

N

Next.js

Easily add fast train scheduling and PNR tracking to Next.js.

R

React

Get started installing and initializing IRCTC Connect in a React App.

E

Express

Learn about installing and initializing APIs in an Express server.

V

Vanilla Node

Use IRCTC Connect cleanly with pure Javascript to query data.

Installation

Terminal
npm install irctc-connect

Requirements

  • 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

An API key is required. Call configure(apiKey) once before using any other function — store your key safely in environment variables.
index.js
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 number
Example Usage
const 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}`);
  });
}
Response Structure
{
  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 number
Example Usage
const 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 number
date(string) — Date in dd-mm-yyyy format
Example Usage
const 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')
Example Usage
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}`);
  });
}

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 number
fromStnCode(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 format
coach(string) — Class: 2S, SL, 3A, 3E, 2A, 1A, CC, EC
quota(string) — Quota: GN, LD, SS, TQ
Example Usage
const 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

CodeDescription
CNFSeat is confirmed
WLNot confirmed yet
RACPartially confirmed
CANTicket cancelled
PQWLOn pooled quota
TQWLOn tatkal quota
GNWLOn 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