Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

RailOne / OneRail (India) (formerly SwaRail) - Sample API program for ticket booking

Last updated on 4 days ago
K
KevinMember
Posted 4 days ago
Official API is not available yet, until IRCTC / CRIS publishes the API spec, here’s a hypothetical sample of what a RailOne (Train Booking) API might look like, based on standard patterns. You can use this as a template.

Hypothetical RailOne API Sample Spec
Base URL
https://api.railone.india/ // example

Authentication

OAuth2 Bearer token or API key header

Sample:

Authorization: Bearer <access_token>

Endpoints
Endpoint Method Description
/trains/search POST Fetch list of trains between source-destination for a date
/stations/{code} GET Get details of a station (name, code, location)
/pnr/status GET Check status of a PNR number
/booking/create POST Create a train reservation (book ticket)
/booking/cancel POST Cancel a booking
/user/login POST Authenticate user
/user/profile GET / PUT Fetch or update user profile
Example Request/Response
1. Search trains

Request

POST /trains/search HTTP/1.1
Host: api.railone.india
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

{
"from_station_code": "MAS", // eg. Chennai
"to_station_code": "NDLS", // New Delhi
"date_of_journey": "2025-10-15",
"quota": "General",
"class": "3A" // 3A, 2A, Sleeper etc.
}


Response (200 OK)

{
"trains": [
{
"train_number": "12615",
"train_name": "Chennai–New Delhi Duronto Express",
"departure_time": "22:00",
"arrival_time": "07:30",
"duration": "9h30m",
"classes_available": [
{
"class_code": "1A",
"fare": 3450,
"availability_status": "AVAILABLE"
},
{
"class_code": "3A",
"fare": 2150,
"availability_status": "AVAILABLE"
}
]
},
{
"train_number": "12617",
"train_name": "Chennai Rajdhani Express",
"departure_time": "18:30",
"arrival_time": "05:15",
"duration": "10h45m",
"classes_available": [
{
"class_code": "2A",
"fare": 3050,
"availability_status": "WL" // Waitlist
},
{
"class_code": "3A",
"fare": 2150,
"availability_status": "AVAILABLE"
}
]
}
]
}

2. Create Booking

Request

POST /booking/create HTTP/1.1
Host: api.railone.india
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

{
"train_number": "12615",
"from_station": "MAS",
"to_station": "NDLS",
"date_of_journey": "2025-10-15",
"class": "3A",
"quota": "General",
"passengers": [
{
"name": "Alice Sharma",
"age": 30,
"gender": "F",
"berth_preference": "Lower"
},
{
"name": "Rajesh Kumar",
"age": 45,
"gender": "M",
"berth_preference": "Upper"
}
],
"payment": {
"method": "CreditCard",
"card_number": "4111111111111111",
"expiry": "12/27",
"cvv": "123"
}
}


Response (success, 201 Created)

{
"booking_id": "BKG1234567890",
"pnr": "8765432109",
"status": "CONFIRMED",
"train_number": "12615",
"journey_details": {
"from": "MAS",
"to": "NDLS",
"date": "2025-10-15",
"departure_time": "22:00",
"arrival_time": "07:30"
},
"passengers": [
{
"name": "Alice Sharma",
"berth": "Lower",
"coach": "S3",
"seat_number": "35"
},
{
"name": "Rajesh Kumar",
"berth": "Upper",
"coach": "S3",
"seat_number": "66"
}
],
"fare_total": 4300,
"booking_timestamp": "2025-10-06T12:45:30Z"
}
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?
Users Online Now
Guests Online 4
Members Online 0

Total Members: 19
Newest Member: bokovac