Coach Composition

GETGET /v1/train/:number/coaches?blueprints=false&stationVariations=false

Description

Rake formation for a train: coach position order from the locomotive, per-class summary counts, reversals where the train changes direction, and per-leg formations for trains that run different rakes on different sections. Berth layouts and per-station formations are available as opt-in extras because they are large.

Parameters

NameInTypeRequiredDescription
numberPATHstringYESPath param - 5-digit train number, e.g. 12919.
blueprintsQUERYbooleanNOQuery param - include per-class berth layouts (cabins, berth types). Default false.
stationVariationsQUERYbooleanNOQuery param - include per-station formations (very large payload). Default false.

Code Example

javascript
const res = await fetch(
  "https://railway-engine.apkscope.workers.dev/v1/train/12919/coaches?blueprints=true",
  { headers: { "x-api-key": "YOUR_KEY" } },
);

const { status, data, error } = await res.json();
if (status === "SUCCESS") {
  console.log(data.trainName, data.totalCoaches, "coaches -", data.coachPosition);
  console.log("reverses at:", data.reversals.join(", ") || "none");
  for (const c of data.rake) {
    console.log(c.position, c.code, c.classType, c.name, c.totalBerths + " berths");
  }
  if (data.blueprints) console.log("3A layout:", data.blueprints["3A"].layout.cabins.length, "cabins");
} else {
  console.error(status, error?.code, error?.message);
}

Notes

Errors: 400 INVALID_REQUEST (bad number or non-boolean flag), 404 TRAIN_NOT_FOUND, 429 RATE_LIMITED, 503 PROVIDER_UNAVAILABLE. `blueprints` and `stationVariations` are null unless requested. Rake data changes rarely, so responses are cached for up to 24 hours; `observedAt` is the provider's generation time, not an observation of live positions. Rakes are pooled and can change without notice — treat a formation as a plan, not a guarantee.

Response Example

JSON response
200JSON