irctc-api 🚆
The official, ultra-fast Python SDK for the IRCTC Developer Network. Zero external dependencies, typed exceptions, and sub-10ms response times for Indian Railways train intelligence, live GPS status, station boards, and PNR enquiries.
⚡ Highlights
- Zero Dependencies: Pure Python standard library (
urllib). Installs in <0.3s, zero dependency conflicts, lightweight (<20 KB). - Sub-10ms Offline Lookups: Instant train schedules, route halts, and station autocomplete from an in-memory 10,647-route corpus.
- Multi-Provider Failover: PNR checks resolve in 2.9s with passenger berth allocations (
LOWER,MIDDLE,SIDE UPPER), platform numbers, and coach positions. - Live GPS Telemetry: Dual-engine failover (~180–350ms) for real-time train running status, delay minutes, and upcoming stations.
- 10,000 Free Credits: Get your API key in 5 seconds with 1-click Google Login at irctc.dev (no credit card required).
📦 Installation
pip install irctc-api
🚀 Quickstart
from irctc import RailEngine
# Initialize with your API key from https://irctc.dev
rail = RailEngine("YOUR_API_KEY")
# 1. Check PNR Status (2.9s multi-provider resolution)
pnr = rail.pnr.check("2265248473")
print(f"Train: {pnr['train_name']} ({pnr['train_number']})")
for p in pnr.get("passengers", []):
print(f" Passenger {p['number']}: {p['current_status']} [Berth: {p['berth']}]")
# 2. Live Train GPS Running Status (~180ms latency)
live = rail.live.get_status("12557")
print(f"Current Station: {live['current_station_name']} | Delay: {live['delay_minutes']} mins")
# 3. Calculate Ticket Fare Breakup (Base, GST, Superfast, Catering)
fare = rail.trains.get_fare("12558", from_station="ANVT", to_station="MFP", travel_class="all")
for cls, details in fare.get("classes", {}).items():
print(f"Class {cls}: ₹{details['totalFare']}")
# 4. Today's Cancelled Trains Across Indian Railways
cancelled = rail.trains.get_cancelled()
print(f"Total cancelled trains today: {len(cancelled)}")
🛠️ Complete Method Catalog
🚆 Trains Namespace (rail.trains)
| Method | Parameters | Description |
|---|---|---|
rail.trains.search() |
from_station, to_station, date=None |
Search running trains between two stations. |
rail.trains.search_by_name() |
name |
Autocomplete train search by partial or full name. |
rail.trains.get_schedule() |
train_no |
Complete train timetable, days of run, and route halts. |
rail.trains.get_fare() |
train_no, from_station, to_station, travel_class="all", quota="GN" |
Official IRCTC ticket fare breakdown (Base, Superfast, GST, Catering). |
rail.trains.get_cancelled() |
None | Daily fully and partially cancelled trains list (0ms cache). |
rail.trains.get_availability() |
train_no, from_station, to_station, date, travel_class="3A", quota="GN" |
14-day live PRS seat availability calendar forecast. |
rail.trains.get_chart_vacant() |
train_no, boarding_station, date="", travel_class="ALL" |
Real-time vacant berths after chart preparation (Current Booking). |
📍 Stations Namespace (rail.stations)
| Method | Parameters | Description |
|---|---|---|
rail.stations.search() |
query |
Instant station autocomplete suggestions by name or code. |
rail.stations.get_by_code() |
code |
Station details, state, division, zone, and coordinates. |
rail.stations.get_timetable() |
code, date=None |
Scheduled trains passing through a specific station. |
📡 Live Status Namespace (rail.live)
| Method | Parameters | Description |
|---|---|---|
rail.live.get_status() |
train_no, date=None |
Real-time GPS running status, delays, and upcoming halts. |
rail.live.get_station() |
station_code, hours=2, to_station=None |
Real-time NTES live station display board (arrivals & departures). |
🎫 PNR Namespace (rail.pnr)
| Method | Parameters | Description |
|---|---|---|
rail.pnr.check() |
pnr_number |
Real-time 10-digit PNR status check with berth normalization. |
🩺 System Health (rail.health)
health = rail.health()
print(health) # {'status': 'healthy', 'uptime': 34210, 'corpus': '10,647 routes loaded'}
🛡️ Error Handling
The client provides typed exceptions mapped directly to API responses:
from irctc import RailEngine
from irctc.exceptions import (
AuthenticationError,
InsufficientCreditsError,
RateLimitError,
NotFoundError,
TimeoutError,
IrctcApiError
)
rail = RailEngine("YOUR_API_KEY")
try:
pnr = rail.pnr.check("2265248473")
except AuthenticationError:
print("Invalid or missing API key. Get one at https://irctc.dev")
except InsufficientCreditsError:
print("Zero credits remaining. Recharge ₹99 for 100,000 credits on irctc.dev")
except RateLimitError as e:
print(f"Rate limit exceeded: {e}")
except NotFoundError:
print("Train or PNR not found.")
except TimeoutError:
print("Network request timed out.")
except IrctcApiError as e:
print(f"API Error [{e.status_code}]: {e.message}")
⚙️ Configuration & Environment Variables
You can configure the client via environment variables instead of hardcoding keys:
export IRCTC_API_KEY="re_live_your_secret_key"
export IRCTC_API_BASE_URL="https://api.irctc.dev" # Optional
import os
from irctc import RailEngine
# Automatically reads from IRCTC_API_KEY
rail = RailEngine()
Custom timeout and headers:
rail = RailEngine(
api_key="re_live_...",
timeout=15.0, # 15 seconds timeout
headers={"x-custom-tag": "telegram-bot"}
)
🤝 Community & Support
- Portal & API Keys: https://irctc.dev
- Documentation: https://irctc.dev/docs
- Interactive Playground: https://irctc.dev/playground
- Email: support@irctc.dev
📄 License
MIT License. Copyright (c) 2026 IRCTC Developer Network.
Metadata
Release files for irctc-api 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| irctc_api-1.0.1.tar.gz | 15.2 kB | Without provenance | Details for irctc_api-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| irctc_api-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for irctc_api-1.0.1-py3-none-any.whl |
Total release size: 25.9 kB
Release files / irctc_api-1.0.1.tar.gz
| Download URL | irctc_api-1.0.1.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d21b449d6dcb9456d5c691458e2b1058c3fbcbbedaa8d6dded5dbf99b4a4a1c1
|
|
BLAKE2b-256 checksum How to use checksums |
16f84120635a3980e45ffc4f7f931fc3de818f081c48b8868a1e8a748dd603f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / irctc_api-1.0.1-py3-none-any.whl
| Download URL | irctc_api-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fce0364e3dbd8ae6bc9773d9a392ae88f2d01d4f61b4b9935c3653c749672af
|
|
BLAKE2b-256 checksum How to use checksums |
72077134d002a5e886f7556c4f9edfb15170dd10c51e681c3678a25be5a7903f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for irctc-api 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.