Brief description
This dataset provides real-time information on road traffic conditions, including traffic flow, accidents and short- or long-term roadworks. It is designed to give users access to up-to-date, usable data for analysis, mobility applications or traffic information services.
Functional description
Format
The messages are provided in DATEX II format. DATEX II is the standard for the exchange of road traffic data. The format is based on a specific XML schema.
Update frequency
The data is updated in real time according to traffic conditions by traffic operators at the Swiss Traffic Management Center VMZ-CH, by cantonal police forces and by territorial units in charge of road operation and maintenance. The API does not provide historical data.
Message types
Three types of traffic situations are published:
- New traffic situation
A message announcing a new situation on our roads. A traffic situation can contain information on a current event such as an oncoming vehicle, an accident or a traffic overload, as well as their causes and an estimate of the duration of the disruption. A traffic situation can also contain information about roadworks or a planned intervention on a specific stretch of road. The duration of the work and details such as the reduction in traffic lanes and the maximum width authorized for heavy goods vehicles are also included.
An example of a new traffic situation can be viewed here. - Update of an existing traffic situation
A message that announces a modification of an existing situation. The modification may update basic information, add causes to an event, or provide details of the length of a traffic jam following the event. An update replaces the original message.
An update is always linked to a base situation via the <situation id=xxx> attribute.
In addition, an update can also be linked to a base situation via the element <situationRecordCreationTime>. This element is unique, because it is accurate to the millisecond.
Example: <dx223:situationRecordCreationTimexsi:type=”dx223:DateTime”>2025-05-01T13:05:02.679000Z</dx223:situationRecordCreationTime>
An example of an update can be viewed here. - Revocation of a traffic situation
A message announcing the end and deletion of a traffic situation. From the moment a traffic situation is revoked, the situation remains active and available on the platform for 60 minutes, with the revoked status entered in the element <dx223:value>. This allows users to find out about the revocation. For traffic situations containing information on roadworks, revocation is not necessary, as the validity of these is generally characterized by a start and end date.
An example of a revocation can be found here.
Technical description
API request
General instructions for accessing our APIs: https://opentransportdata.swiss/de/howto-access-api
URL of the API: https://api.opentransportdata.swiss/TDP/Soap_Datex2/TrafficSituations/Pull
Structure of the API request
Header
The SoapAction and API key must be transmitted in the header:
Constraint | Attribute | Value |
Mandatory | SoapAction | http://opentransportdata.swiss/TDP/Soap_Datex2/Pull/v1/pullTrafficMessages |
Mandatory | Authorization | [Your API key] |
Optional * | If-Modified-Since | [Date & time] –> Format: 2025-05-01T00:00:06.83+01:00 |
The “If-Modified-Since” attribute allows you to define the date and time of the last request, so as to obtain only those messages that arrived between that time and the current time. If this attribute is not specified, the API returns all traffic situations that are active or in the process of being revoked (“revoked” status).
* IMPORTANT: If an ‘If-Modified-Since’ is not used, a large part of the data is repeated (and the amount of data is therefore large). Consequently, we recommend:
- One query per day without If-Modified-Since and then only queries with If-Modified-Since with a timestamp within the last 5 minutes.
- When the application that retrieves the data is restarted, a query can also be made without If-Modified-Since.
Body
The body of the request message is always the same.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<d2LogicalModel xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" modelBaseVersion="2" xmlns="http://datex2.eu/schema/2/2_0">
<exchange>
<supplierIdentification>
<country>ch</country>
<nationalIdentifier>FEDRO</nationalIdentifier>
</supplierIdentification>
<subscription>
<operatingMode>operatingMode1</operatingMode>
<subscriptionStartTime>2025-05-01T08:00:00.00+01:00</subscriptionStartTime>
<subscriptionState>active</subscriptionState>
<updateMethod>singleElementUpdate</updateMethod>
<target>
<address></address>
<protocol>http</protocol>
</target>
</subscription>
</exchange>
</d2LogicalModel>
</soap:Body>
</soap:Envelope>
Date format
The date format used in DATEX II allows users to determine date and time according to their time zone. To this end, the ISO 8601 format is recommended for all dates defined in DATEX II.
Georeferencing
Traffic messages are localised according to the TMC (Traffic Message Channel) standard and the “AlertC” method. The version of the TMC topology used is defined in the element <dx223:alertCLocationTableVersion>. The direction in which a “Traffic Situation” has an effect can therefore be determined automatically. Access to the TMC topology can be requested by e-mail at verkehrsdaten-plattform@astra.admin.ch. Please indicate the version you require in your request.