Skip to content
jouniso edited this page May 26, 2017 · 8 revisions

Data APIs (REST/JSON ja WebSocket)

Swagger API-documentation and sandbox for testing data APIs

http://tie.digitraffic.fi/api/v1/data/documentation/swagger-ui.html#/data

Current data of cameras

http://tie.digitraffic.fi/api/v1/data/camera-data/camera-data

http://tie.digitraffic.fi/api/v1/data/camera-data/{id}

The message contains all public camera presets including url where you can find the camera pictures. For example image for camera preset C0150200 can be found at http://weathercam.digitraffic.fi/C0150200.jpg.

Kelikamerakuva C0150200.

Current fluency data of links including journey times

http://tie.digitraffic.fi/api/v1/data/fluency-current

http://tie.digitraffic.fi/api/v1/data/fluency-current/{id}

Only links of Helsinki Metropolitan Area are measured. Link numbers are 1 to 3 digits long and under 1000 for Helsinki Metropolitan Area.

The message contains for each link the latest 5 minute median, corresponding average speed, fluency class, and timestamp of the latest update.

The message is updates each time we receive new median data from MTP. Normally this is once per minute. If MTP does not send us new data, the message is not updated.

History data of links for previous day

http://tie.digitraffic.fi/api/v1/data/fluency-history-previous-day

http://tie.digitraffic.fi/api/v1/data/fluency-history-previous-day/{id}

Only links of Helsinki Metropolitan Area are measured. Link numbers are 1 to 3 digits long and under 1000 for Helsinki Metropolitan Area.

The message contains for each link all the median data from the previous day: median travel time, average speed and fluency class. The message contains all the available medians for each link, so there are (at most) 1440 medians per each link.

A batch process updates the messages once each day. The updated message is available at 02:30 Finnish time each night.

Due to the large size of the message, it must not be retrieved more than once per each day.

History data of link for given month

http://tie.digitraffic.fi/api/v1/data/fluency-history/{id}?year={year}&month={month}

Only links of Helsinki Metropolitan Area are measured. Link numbers are 1 to 3 digits long and under 1000 for Helsinki Metropolitan Area.

The message contains history data for given link from the begining to the end of the given month.

Current free flow speeds

http://tie.digitraffic.fi/api/v1/data/free-flow-speeds

http://tie.digitraffic.fi/api/v1/data/free-flow-speeds/link/{id}

http://tie.digitraffic.fi/api/v1/data/free-flow-speeds/tms/{id}

Only links of Helsinki Metropolitan Area are measured. Link numbers are 1 to 3 digits long and under 1000 for Helsinki Metropolitan Area.

The message contains the current free flow speed values for links and TMS stations.

When a link or a TMS station changes from winter speed limits to summer speed limits, or vice versa, the contents of this message change.

A batch process updates the messages once each day. The updated message is available at 03:30 Finnish time each night.

Current road weather forecasts

http://tie.digitraffic.fi/api/v1/data/road-conditions

The message contains weather forecasts for road parts and its updated every five minutes.

Current data of TMS Stations (Traffic Measurement System / LAM)

http://tie.digitraffic.fi/api/v1/data/tms-data

http://tie.digitraffic.fi/api/v1/data/tms-data/{id}

The message contains the latest measurement data from TMS Stations (Traffic Measurement System / LAM) stations.

The message contains all sensor data available, for each TMS station, including traffic volume in both directions and average speed in both directions.

The data is updated practically in realtime, but to ensure performance outbound messages are cached for one minute.

Simple WebSocket JavaScript client:

<html>
     <head>
         <title>Testiclient for lam sensor values</title>
         <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js" ></script>
         <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.0.3/sockjs.min.js"></script>
         <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>
         <script>
             function connect() {
                 var url = "ws://tie.digitraffic.fi/api/v1/plain-websockets/tmsdata";
                 var socket = new WebSocket(url);
                 socket.onopen = function (event) {
                     console.info('Socket is open');
                 }
                 socket.onmessage = function(message) {
                     addMessage(message);
                 };
             }
             function addMessage(message) {
                 var text = convert(message);
                 $(".messages").append(text);
                 $(".messages").append('\n');
             }
             function convert(message) {
                 return JSON.stringify(JSON.parse(message.data));
             }
             connect();
         </script>
     </head>
     <body>
         <b>All messages:</b>
         <pre class="messages"></pre>
     </body>
 </html>

Current data of Weather Stations

http://tie.digitraffic.fi/api/v1/data/weather-data

http://tie.digitraffic.fi/api/v1/data/weather-data/{id}

The message contains the latest measurement data from road weather stations.

The message contains for each road weather station the sensor values provided by the station.

The data is updated practically in realtime, but to ensure performance outbound messages are cached for one minute.

Clone this wiki locally