Fare Enquiry

GETGET /v1/train/:number/fare?source=&destination=&class=&quota=GN&date=YYYY-MM-DD

Description

Itemised fare quote for one train, one date, one travel class and one quota: base fare, reservation and superfast charges, GST, tatkal and dynamic components, and the total, together with the distance. Every charge comes from the fare engine as reported — nothing is rounded, estimated or filled in.

Parameters

NameInTypeRequiredDescription
numberPATHstringYESPath param - 5-digit train number, e.g. 12919.
sourceQUERYstringYESQuery param - boarding station code, e.g. DADN.
destinationQUERYstringYESQuery param - destination station code, e.g. SVDK.
classQUERYstringYESQuery param - travel class code, e.g. 3A, 2A, SL, EC.
quotaQUERYstringNOQuery param - booking quota code. Default GN (general). Also TQ, SS and similar.
dateQUERYstringNOQuery param - journey date in YYYY-MM-DD. Omit for today. Allowed: yesterday to +90 days.

Code Example

javascript
const res = await fetch(
  "https://railway-engine.apkscope.workers.dev/v1/train/12919/fare?source=DADN&destination=SVDK&class=3A&quota=GN",
  { headers: { "x-api-key": "YOUR_KEY" } },
);

const { status, data, error } = await res.json();
if (status === "SUCCESS" || status === "STALE_DATA") {
  console.log(data.trainName, data.distanceKm + "km", data.classCode, data.quotaCode);
  console.log("total", data.breakdown.totalFare, "base", data.breakdown.baseFare);
  console.log("GST", data.breakdown.goodsServiceTax, "superfast", data.breakdown.superfastCharge);
} else {
  console.error(status, error?.code, error?.message);
}

Notes

One class per request: to compare classes, call the endpoint once per class code (the value in `summary` of GET /v1/train/:number/coaches lists the classes a train actually carries) and respect the 60 req/min limit. Charges the fare engine does not report are null, never zero. Errors: 400 INVALID_REQUEST (missing source/destination/class, bad class or quota code, date outside the window), 404 TRAIN_NOT_FOUND, 429 RATE_LIMITED, 503 PROVIDER_UNAVAILABLE. Quotas such as tatkal open at fixed times; a quote is valid for the journey date shown, not a booking guarantee.

Response Example

JSON response
200JSON