#AutoTranslate
Brief Description
Formation data is information about the wagons (and locomotives) in a train, including the composition of a train. Formation data includes not only the position of individual wagons in a train, but also the characteristics of individual wagons.
Since autumn 2024, we have been offering a REST API. This makes the formation data of a train for a specific train number on a specific operating day available in the form of a JSON data structure.
Our formation data can be used to find out, for example, which coach on a specific train (with a specific train number) offers low-floor access, i.e. convenient access for wheelchairs or pushchairs.
With the ‘Train Formation Visualization‘ we also provide a visualisation to display the API data for a train (see the following screenshot). To do this, the train number must first be determined from an online timetable, e.g. of https://www.bls.ch.
https://opentdatach.github.io/train-formation-view
Access the API
Please note:
Note: A description of how to access the APIs can be found here: Howto: Accessing our APIs with API Keys.
Functional Description
Who is behind it?
The service is provided by the Customer Information Plus (SKI+) System Tasks team on behalf of the Federal Office of Transport (FOT) in Switzerland.
We obtain the data for the formations from these two systems:
- The training service (FOS) of SBB, with various railway undertakings (EVU) deliver their formation data. The list of permitted EVU is limited to those who have given their consent to the use of their formation data.
- The transport interface of the real-time system (CUS) of the customer information system tasks (SKI). CUS manages real-time data on all modes of public transport in Switzerland.
While the FOS interface only provides details about the formations, the CUS interface adds further details to the data, particularly the position of the wagons (sectors) at the tracks at each stop.
Why does opentransportdata.swiss offer this?
The data about the formation of a train can be used to inform users:
- which sector of the platform at the station allows wheelchair-accessible boarding which is particularly important in connection with the Disability Discrimination Act (DDA)
- coaches which have bicycle hooks available,
- how many seats are generally available in a coach,
- in combination with our Occupancy rate forecast the expected occupancy rate of the train can even be displayed,
- which locomotive and wagon types run on which routes, for trainspotters or for transport companies that combine their services with other railways.
Technical Description
What services (interface endpoints) does our train formation service offer?
Our train formation service supports the following three request variants. The details of the requests are also documented via the OpenAPI interface:
- Stop-based – https://api.opentransportdata.swiss/formation/v2/formations_stop_based:
- This service provides the formations for each individual stop along a train’s journey.
- Parameters:
- The name of a EVU.
- An operating day: The day for which the formation is to be queried. The date cannot be in the past. Please note: The date can only be today’s (due to inclusion of CUS real-time data).
- The train number, also known as the means of transport number: The train for which you want to enquire about the formation. This number can be obtained in various ways, including via our timetable data in various data formats.
- Return values: a JSON data structure with:
- the stops a train stops, with details of the stops, the formation the train departs from the stops, and when, from which track, and which locomotives/coaches remain together to where. The crucial point here is that we specify the formation in a compact notation originating from CUS.
- This query does not contain all details for every coach.
- The interpretation of the formation short string is described below.
- Possible use case: To display the formation of a train on a track for a specific stop.
- Train-based – https://api.opentransportdata.swiss/formation/v2/formations_vehicle_based:
- This service supplies the formations for each vehicle (i.e. for each formation element) in the train.
- Parameters:
- The same as in
formations_stop_based. - Operating day: The day for which the formation is to be queried. The date can be up to three days in the future.
- The same as in
- Return values: a JSON data structure with:
- the formation elements with the details of each vehicle, the position of the vehicle in the formation, as well as the stops where the vehicle stops along the journey, with details of the stop, and the track and sector where the vehicle stops at each stop.
- This query does not include the overall view of the train along the stops.
- Possible use case: Tracking a specific wagon.
- Stop and train-based – https://api.opentransportdata.swiss/formation/v2/formations_full
- This service provides the formations for each stop as well as for each vehicle.
- Parameters: same as for formations_stop_based and formations_vehicle_based.
- Return values: a JSON data structure with the stops and the formation elements as in the respective variants described above.
- Status info about the service – https://api.opentransportdata.swiss/formation/v2/health
- This endpoint provides the status of the current operating state.
- Parameters: none.
- Return values: A JSON data structure with the current state of the service.
The query parameters
The following parameters are passed as query parameters after a ‘?’ in the URL (GET request):
| Parameters | Value description and example value |
|---|---|
evu |
The EVU (railway undertaking) for whom the request is to be made. The following are currently supported: BLSP, SBBP, MBC, OeBB, RhB, SOB, THURBO, TPF, TRN, VDBB, ZB, and SZU (since 2026-11-09). |
operationDate |
The date on which the train runs and for which the enquiry is to be made. Example: 2024-09-18. |
trainNumber |
The train number for which you want to query the formation data. Example: 2806. |
An example request would therefore be: https://api.opentransportdata.swiss/formation/v2/formations_stop_based?evu=BLSP&operationDate=2025-08-28&trainNumber=2806
The answer
We will not describe the full data model here, but instead refer to the following YAML:
Interpretation of the formation short string:
Basically, the structure of the string differs depending on whether a track has sectors or whether we are aware of these.
In any case, the following applies to the structure:
| Element | Description |
|---|---|
| Sector | Letter („A“ … „Z“) |
| Status | „-“ Vehicle closed
„>“ Vehicle with groups boarding at this BP
„=“ Vehicle (partly) reserved for groups in transit
„%“ Vehicle open but unstaffed (dining car only)
Note: ‘closed’ can only occur on its own, the other characters can be combined |
| [ | Start of the vehicle group belonging to the train
Note: This makes it possible to distinguish between vehicles that are parked or to be parked and those belonging to the moving train. |
| ]
|
End of the vehicle group belonging to the train
Note: This makes it possible to distinguish between vehicles that are parked or to be parked and those belonging to the moving train. |
| (
|
no passage to the neighbouring vehicle on this side of the vehicle possible
Note: The calculation is based on master data and assumptions. There is no guarantee that these figures will always correspond to reality. |
| )
|
no passage to the neighbouring vehicle on this side of the vehicle possible
Note: The calculation is based on master data and assumptions. There is no guarantee that these figures will always correspond to reality. |
| VehicleTypeKI
|
Vehicle type from the point of view of customer information. These mean:
– ‘1’ 1st class passenger coach – ‘2’ passenger coach 2nd class (also downgraded A/AB) – ‘12’ 1st and 2nd class passenger coaches – ‘CC’ couchette car – ‘FA’ family coach – ‘WL’ sleeping car – ‘WR’ Restaurant (bistro car, dining car, etc.) – ‘W1’ combined dining car and 1st class seating car – ‘W2’ combined dining car and 2nd class seating car – ‘LK’ traction unit – ‘D’ luggage trolley – ‘F’ fictitious car – ‘K’ Classless vehicle – ‘X’ parked coach Note: CUS converts the vehicle type purchased from FOS into a generic ‘AI type’. The following variants are used: 1. Conversion of extra-long vehicles: Multiple units that deliver to the source not as wagons but as one (extra-long) vehicle can be configured by CUS into individual wagons. The string then does not contain 1 vehicle (usually of the type „12“), but 2…n vehicles of the following „1“, „2“, „12“ or „D“. The number is calculated on the basis of the number of vehicles perceived by the customer. Vehicles of this type, which do not have first class seats in the middle of the train, are generally classless vehicles of the following „K“ converted.
2. Conversion of individual vehicles based on regular expressions: All individual vehicles are converted into generic AI vehicles via prioritized regular expressions. 3. Conversion of individual vehicles based on the number of seats: If no regular expression in (2) matches, the type is determined on the basis of the number of 1st and 2nd class seats. If the vehicle has no seats, the type „D“ allocated.
Note about “F”: On tracks with sectors, the delta between the length of the train and the length of the stopping edge is filled in at the front and/or at the rear with notional wagons.
Note about “X”: Stabled wagons influence the allocation of vehicles in the train to the sectors but are not part of the train in question. |
| OrdNo | Serial number for the individual seat reservation, which is thus displayed on the passenger coach (1…3-digit number) |
| Offer | List of vehicle-related offers. These include:
– „BHP“ Wheelchair spaces
– „BZ“ Business zone
– „FZ“ Family zone
– „KW“ Pram platform
– „NF“ Vehicle with low-floor access
– „VH“ Bike hooks/platform
– „VR“ bicycle hooks/platform subject to reservation |
What are the most important terms and concepts to know?
We use the following elements as part of our interface (without container elements):
StopPoint- A StopPoint is a stop along the timetable.
StopTime- Departure and arrival times.
Track- The track at the StopPoint.
FormationShortString- The short representation of the formation (as defined by CUS).
VehicleGoal- Which coaches stay together up to which destination, as seen from one stop.
JourneyMetaInformation- Unique identification of the journey.
TrainMetaInformation- Descriptive characteristics of the train.
FormationMetaInformation- Details of the entire formation, e.g. the number of vehicles.
ScheduledStop- StopPoint, StopTime, Track, Details about how the train is used at the stop (e.g. whether the train is stopping or passing) and any changes to the journey (e.g. delays in arrivals).
VehicleIdentifier- Attributes that uniquely identify a vehicle, such as the european vehicle number (EVN). A special feature here is that a vehicle can be part of an articulated train and therefore not its own EVN but only a ‘generated’ one. In this case, the ‘Parent-EVN‘.
WheelchairSymbolProperties- Properties needed to determine the wheelchair symbol (see also Accessibility in timetable information).
AccessibilityProperties- Other properties that can be used in the sense of disability-friendly presentation.
PictoProperties- Whether the different pictography is displayed on a vehicle.
DirectTrolleyInformation- If the formation represents direct coaches.
VehicleRelation- This element makes it possible to track the previous and subsequent journey for the given formation, which can also be a direct coach journey.
VehicleProperties- Characteristics of a vehicle as part of a formation, i.e. a formation element, and from where and to where the wagon is part of the formation.
FormationVehicleAtScheduledStop- The representation of the formation per stop (for the vehicle_based request).
VehicleRelationship- The journey relationship, i.e. how the journey changes between two journeys (e.g. if there is a cancellation).
VehicleRelationshipDetails- The details of a travel relationship.
Restrictions
- The data is limited to railway undertakings (EVU), who provide their training via Swiss Federal Railways (SBB) and have consented to the publication of their data as Open Data.
- The service will only make all the data and the vehicle-based data available if all sources have all the necessary data. This is particularly important considering that CUS only has data for today.
- Specifically, the data comes from the SKI real-time system (CUS – CUstomer Information System – VerkehrsMittel VM) and the Formation Services (FOS) at SBB.
