# IRCTC Train Data Scraper (`scrapingshark/irctc-train-data-scraper`) Actor

The IRCTC Train Data Scraper is an actor designed to automate the extraction of real-time train-related data from the Indian Railway Catering and Tourism Corporation (IRCTC) website. It fetches information such as trains between stations, seat availability, fare details, train routes and more.

- **URL**: https://apify.com/scrapingshark/irctc-train-data-scraper.md
- **Developed by:** [ScrapingShark](https://apify.com/scrapingshark) (community)
- **Categories:** Travel, Other
- **Stats:** 36 total users, 0 monthly users, 97.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$25.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#rental-actors

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## 🚄 IRCTC Train Data Scraper (Live Trains, Seat Availability, Fare Details)

Automate real-time Indian Railways data extraction from the **IRCTC (Indian Railway Catering and Tourism Corporation)** website with this Apify actor.

This actor scrapes **train schedules, routes, ticket fare details, seat availability by class and quota**, and more. It is ideal for **travel aggregators, ticketing platforms, railway data analysis**, or personal travel planning.

***

### ✅ What This Actor Does

The **IRCTC Scraper** fetches a variety of railway-related data from the IRCTC portal based on your input parameters. It supports:

- 🚉 **Search trains between two stations**
- 🎫 **Check real-time seat availability**
- 💰 **Retrieve detailed fare breakdown**
- 🗺️ **View train route and station data**
- 📅 **Select travel date and ticket quota**
- 🚆 **Query ticket classes like Sleeper, AC, Tatkal, etc.**

***

### 📥 Input Schema

The actor accepts a structured JSON input. Here are the supported fields:

```json
{
  "startingStation": "NDLS",
  "destinationStation": "MMCT",
  "startDate": "2025-07-30",
  "quota": "GN",
  "trainNumber": "12138" # only required for getFareDetails,
  "ticketClass": "SL" # only required for getFareDetails
}
```

### 🔧 Input Properties

| Field                | Type     | Description                                                                                                  |
| -------------------- | -------- | -------------------------------------------------------------------------------------------------------------|
| `startingStation`    | `string` | IRCTC station code where the journey starts (e.g., `NDLS`)                                                   |
| `destinationStation` | `string` | IRCTC station code where the journey ends (e.g., `MMCT`)                                                     |
| `startDate`          | `string` | Journey date in `YYYY-MM-DD` format                                                                          |
| `quota`              | `string` | Ticket quota (e.g., `GN` - General, `TQ` - Tatkal, `SS` - Senior Citizen)                                    |
| `trainNumber`        | `string` | (Optional - Only required for getFareDetails) Train number for fare or availability inquiry                  |
| `ticketClass`        | `string` | (Optional - Only required for getFareDetails) Class of travel (`SL`, `3A`, `1A`, `CC`, etc.)                 |

### 📤 Sample Output

#### 🚄 Trains Between Stations

```json
{
  "trainNumber": "12138",
  "trainName": "PUNJAB MAIL",
  "fromStnCode": "NDLS",
  "toStnCode": "CSMT",
  "arrivalTime": "07:35",
  "departureTime": "05:10",
  "distance": "1544",
  "duration": "26:25",
  "runningMon": "Y",
  "runningTue": "Y",
  "runningWed": "Y",
  "runningThu": "Y",
  "runningFri": "Y",
  "runningSat": "Y",
  "runningSun": "Y",
  "avlClasses": [
    "1A",
    "2A",
    "3A",
    "SL"
  ],
  "trainType": [
    "O"
  ],
  "atasOpted": "false",
  "flexiFlag": "false",
  "trainOwner": "0",
  "trainsiteId": "D",
  "fromStnName": "NEW DELHI",
  "fromStnUtterances": [],
  "fromStnNameHi": "नई दिल्ली",
  "fromStnDistrict": "Central",
  "fromStnState": "Delhi",
  "fromStnTraincount": "244",
  "fromStnLatitude": 28.642314,
  "fromStnLongitude": 77.22000399999999,
  "fromStnAddress": "Pedestrian Opas, Ratan Lal Market, Railway Colony, Paharganj, New Delhi, Delhi 110006",
  "fromStnNameGu": "નઈ દિલ્લી",
  "toStnName": "C SHIVAJI MAH T",
  "toStnUtterances": [],
  "toStnNameHi": "स शिवजी मह त",
  "toStnDistrict": "",
  "toStnState": "Maharashtra",
  "toStnTraincount": "103",
  "toStnLatitude": 18.941002233498335,
  "toStnLongitude": 72.83463833978938,
  "toStnAddress": "Chhatrapati Shivaji Terminus Area, Fort, Mumbai, Maharashtra 400001",
  "toStnNameGu": "સ શિવજી મહ ત"
}
```

#### 🎫 Get Fare Details

```json
{
  "availablityDate": "30-7-2025",
  "availablityStatus": "AVAILABLE-0009",
  "reasonType": "S",
  "availablityType": "1",
  "currentBkgFlag": "N",
  "wlType": "8224",
  "delayFlag": "N",
  "delay": "0",
  "fromStnName": "MGR CHENNAI CTL",
  "fromStnUtterances": [],
  "fromStnNameHi": "मगर चेन्नै कत्ल",
  "fromStnNameGu": "એમજીઆર ચેન્નઈ કંટલ",
  "fromStnDistrict": "Chennai",
  "fromStnState": "Tamil Nadu",
  "fromStnTraincount": "179",
  "fromStnLatitude": 13.0847613,
  "fromStnLongitude": 80.27485630000001,
  "fromStnAddress": "General Hospital Rd, Kannappar Thidal, Periyamet, Chennai, Tamil Nadu 600003",
  "toStnName": "BENGALURU CANT",
  "toStnUtterances": [],
  "toStnNameHi": "बेंगलूरु चैंट",
  "toStnDistrict": "Bangalore",
  "toStnState": "Karnataka",
  "toStnTraincount": "72",
  "toStnLatitude": 12.9936735,
  "toStnLongitude": 77.59932690000001,
  "toStnAddress": "Bengaluru, Karnataka",
  "toStnNameGu": "બેંગલૂરુ ચૈંટ",
  "trainName": "KAVERI EXPRESS",
  "distance": "358",
  "reqEnqParam": "16021#MAS#BNC#MAS#SL",
  "quota": "SS",
  "enqClass": "SL",
  "trainNo": "16021",
  "baseFare": "215",
  "reservationCharge": "20",
  "superfastCharge": "0",
  "fuelAmount": "0.0",
  "totalConcession": "0",
  "tatkalFare": "0",
  "serviceTax": "0.0",
  "otherCharge": "0",
  "cateringCharge": "0",
  "dynamicFare": "0",
  "totalFare": "235",
  "travelInsuranceCharge": "0.0",
  "travelInsuranceServiceTax": "0.0",
  "insuredPsgnCount": "0",
  "nextEnqDate": "2025-08-05T00:00:00.000",
  "preEnqDate": "2025-07-28T00:00:00.000",
  "timeStamp": "2025-07-28T20:14:09.434",
  "otpAuthenticationFlag": "0",
  "cateringFlag": "A",
  "totalCollectibleAmount": "235.0",
  "fromStnCode": "MAS",
  "toStnCode": "BNC"
}
```

### 🔎 Use Cases

- Travel booking platforms showing live train and fare data

- Custom travel planners

- Pricing comparison and fare analytics tools

- Railway data visualizations and dashboards

### 📬 Contact Us

Need additional features or help to solve your specific scraping problem?\
📧 **scrapingshark@gmail.com**

# Actor input Schema

## `startingStation` (type: `string`):

Select the station where you would onboard

## `destinationStation` (type: `string`):

Select the station where you would like to go to

## `startDate` (type: `string`):

Enter the date on which the journey starts

## `quota` (type: `string`):

Select the ticket quota

## `trainNumber` (type: `string`):

Enter the number of the train where you would like to search for tickets (trainNumber is returned when you search for trains between stations)

## `ticketClass` (type: `string`):

Select the Ticket Class (Available Ticket Classes is returned when you search for trains between stations)

## Actor input object example

```json
{
  "startingStation": "NDLS",
  "destinationStation": "MMCT",
  "startDate": "2025-08-19",
  "quota": "GN"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapingshark/irctc-train-data-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("scrapingshark/irctc-train-data-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call scrapingshark/irctc-train-data-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapingshark/irctc-train-data-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/xNSMjmHC3V9XhKsEd/builds/KoFzw4b8BurOuhrM6/openapi.json
