Fare Enquiry
GET /v1/train/:number/fare?source=&destination=&class="a=GN&date=YYYY-MM-DDDescription
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
| Name | In | Type | Required | Description |
|---|---|---|---|---|
number | PATH | string | YES | Path param - 5-digit train number, e.g. 12919. |
source | QUERY | string | YES | Query param - boarding station code, e.g. DADN. |
destination | QUERY | string | YES | Query param - destination station code, e.g. SVDK. |
class | QUERY | string | YES | Query param - travel class code, e.g. 3A, 2A, SL, EC. |
quota | QUERY | string | NO | Query param - booking quota code. Default GN (general). Also TQ, SS and similar. |
date | QUERY | string | NO | Query param - journey date in YYYY-MM-DD. Omit for today. Allowed: yesterday to +90 days. |
Code Example
const res = await fetch(
"https://railway-engine.apkscope.workers.dev/v1/train/12919/fare?source=DADN&destination=SVDK&class=3A"a=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