A lightweight proxy server for the Shohoz API exclusively designed to fetch and serve train ticket data. This backend does not store or manage data itself; it simply relays requests and responses between clients and the official Shohoz API.
Follow these steps to run the server locally:
-
Clone the repository (if you haven't already):
git clone https://github.com/SazidulAlam47/train-ticket-tracker-server.git cd train-ticket-tracker-server -
Install dependencies:
npm install
-
Configure environment variables:
- Copy
.env.exampleto.envand fill in your credentials:
cp .env.example .env
After copying
.env.exampleto.env, configure the following variables in your.envfile:# PORT: The port number the server will run on (default: 5000) # SHOHOZ_BASE_API: Shohoz API base URL # CLIENT_URL: Allowed client URL for CORS
- Copy
-
Start the server:
npm start
The server will run on the port specified in your .env file (default: 5000).
- Purpose: Acts as a middleware between your frontend/client and the Shohoz API, forwarding requests to retrieve train ticket information.
- No local database, user management, or persistent storage.
- Forwards REST API requests to Shohoz API endpoints
- Returns train ticket data from Shohoz
- Backend: Node.js, Express.js
- Proxy: axios
Description:
Fetch available train tickets between two cities for a specific date.
The server sends your request to the Shohoz API and returns the results in a simplified, consistent format.
{
"from": "Dhaka",
"to": "Khulna",
"date": "2025-06-09"
}from: Departure city (required)to: Destination city (required)date: Travel date inYYYY-MM-DDformat (required)
{
"success": true,
"message": "Tickets are fetched successfully",
"data": [
{
"trainName": "SUNDARBAN EXPRESS (726)",
"departureDateTime": "09 Jun, 08:00 am",
"arrivalDateTime": "09 Jun, 03:40 pm",
"travelTime": "07h 40m",
"from": "Dhaka",
"to": "Khulna",
"class": "AC_S",
"fare": 1245,
"seats": 2,
"now": "2025-05-31T07:07:31.897Z",
"link": "https://eticket.railway.gov.bd/booking/train/search?fromcity=Dhaka&tocity=Khulna&doj=09-Jun-2025&class=AC_S"
},
{
"trainName": "CHITRA EXPRESS (764)",
"departureDateTime": "09 Jun, 07:30 pm",
"arrivalDateTime": "10 Jun, 04:40 am",
"travelTime": "09h 10m",
"from": "Dhaka",
"to": "Khulna",
"class": "S_CHAIR",
"fare": 680,
"seats": 1,
"now": "2025-05-31T07:07:31.897Z",
"link": "https://eticket.railway.gov.bd/booking/train/search?fromcity=Dhaka&tocity=Khulna&doj=09-Jun-2025&class=S_CHAIR"
}
]
}success: Indicates request statusmessage: Human-readable status messagedata: Array of available tickets with train details, timings, fare, seat count, and direct booking link
- Receives POST requests at
/api/v1/tickets - Calls the Shohoz train ticket API with the provided parameters
- Returns ticket data in a consistent, easy-to-use format
This server only uses the Shohoz public API to fetch and relay train ticket information.