Skip to content

GTFS-RT

GTFS Realtime (GTFS RT) is an extension to GTFS Static and enhances the static transit information with real-time information. GTFS real-time data is reconciled with GTFS static data. The real-time feed includes all known changes in public transport in Switzerland in the overall preview window (three hours) for all transport undertakings which deliver real-time data.

Technical description

GTFS RT enables the static transit information to be enhanced with three different types of supplementary information. These three sources of enhancement are usually available separately via HTTP and are updated regularly so that developers can choose which real-time data they would like to use to enhance their applications. It is not clear at present as to exactly which of these data sources will be made available on the Open Data Platform Swiss Public Transport.

The three types of supplementary information are:

  • Trip updates
  • Service alerts
  • Vehicle positions

Trip updates

Example: “18 bus is currently 10 minutes late”

In this case, delays, modified routes, replacement vehicles or cancellations for individual lines are constantly published to enable passengers to plan their journeys as accurately as possible.

Service alerts

Example: “Bern Weissenbühl station is currently closed due to an accident”

If the stop for boarding is moved or generally unforeseen events occur which have an impact on a stop, route or the whole network, brief messages can be published to keep passengers up to date and explain the reason for the change.

Service alerts are not available on the platform.

Vehicle positions

Example: “This bus is located at the Bern Bahnhof stop at 18:23”

In this case, information about the location of individual transit vehicles can be published. In addition, the vehicle’s current occupancy rate, the vehicle type or other similar information can be provided.

Vehicle positions are not available on the platform.

You can find an extensive list of the individual possible information units at https://developers.google.com/transit/gtfs-realtime/reference/

Key concepts

  • GTFS Static: Publication of static transit information in GTFS format.
  • GTFS Realtime: Publication of real-time information to enhance the static GTFS Data, in the form of protocol buffers.

Technical aspects

The SBB provides Trip updates via a GET request.

Authorisation and Open Services

An API keyword is required to access this API. It can be obtained via the Developer Portal. You need a “GTFS-RT Beta” type key. The token must also be sent in the HTTP header as “Authorization”.

Maximum number of requests per minute

You can submit a maximum of two requests a minute to the interface using its key. A sliding window is used.

When the request is made too quickly, the following message is returned:

Reference to GFTS Static

Every GTFS-RT feed is based on an item of GTFS Static data. This is provided during Tuesday. On Wednesday at 14:00, the GTFS-RT feed is switched to the new GTFS Static. As many of the IDs (“service_id”, “trip_id”) are regenerated, it is vital to refer to the correct GTFS to ensure the interface is correctly implemented.

Access URL

HTTP GET at https://api.opentransportdata.swiss/gtfs-rt

(NB: No “/” at the end)

With the Authorization header and Content type= “text/XML” or “application/XML”

Authorization header

Content type: We suggest you set “application/octet-stream”.

Data structure (protocol buffer)

The GTFS real-time data exchange format is based on protocol buffers, which is a language- and platform-neutral mechanism for importing data in a serial sequence. It is designed in binary format, which makes it smaller, faster and simpler than XML. The data structure is defined in a gtfs-realtime.proto file, which is used to generate source code to translate the structured data simply into various languages (Java, C++, Python etc.).

Data structure (JSON)

The platform also provides a JSON implementation as an alternative option.

The request is then submitted via the URL: HTTP GET https://api.opentransportdata.swiss/gtfs-rt?format=JSON

Please note that the JSON option is not standardised.

Accuracy

All delays are only given to the nearest minute. An extension is being devised, but will only come about at a later juncture.

Compression

It will soon be possible to obtain the JSON flow in compressed form too.

The following header must be included to do this:

A compression level of around 90% is achieved. This means that the data will be transferred much more quickly.

Interpretation of data

The GTFS specification can be consulted directly in order to obtain the exact interpretation of the data.

The major special case are platforms, which are described on the GTFS website.

 Other important points

  • An update rule applies to GTFS-RT for delays. If, for instance, a whole journey is 5 minutes late, this is only indicated at the first stop. The delay must be updated at all the other stops during the import process. Arrival and departure times must also be updated.

More detailed information

You can find more detailed information about GTFS Realtime on Google’s GTFS developer website: https://developers.google.com/transit/gtfs-realtime/

Start the discussion at disc.opentransportdata.swiss