Realtime and general purpose open APIs at Digit...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Realtime and general purpose open APIs at Digitransit

Presentation and workshop at API Days Nordic 2016, Tampere, Finland

Tuukka Hastrup

May 19, 2016

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

30 slides
  1. Helsinki Region and Finland • Helsinki regional transport authority (HSL.fi)

    • Finnish Transport Agency (FTA.fi) • Helsinki region: – 1.3 million inhabitants – 1 million boardings per day • Current HSL Journey Planner reittiopas.fi/en/ – 0.2 million users per day – Customers very satisfied: 50% NPS
  2. Enabler role of government • Plan the public transport network

    • Provide open data and open APIs • Support app developers • Support MaaS (Mobility as a Service) startups
  3. Use of HSL data Developer accounts 2009-2012 Sep 09 Data

    opens Sep 10 Apps4Finland Automated sign-up form Feb 11 HSL Mobile Competition 480 30 670 (789) < 5 apps +30 apps Sep 11 Apps4Finland Sep 12 Apps4Finland
  4. HSL APIs dev.hsl.fi Journey planning Realtime departures Schedules Line map

    Disruption info Vehicle locations Biking and walking Open Data dev.hsl.fi +30 mobile apps
  5. Routes Schedules Analyses Basic service Applications and services Quality monitoring

    Traffic planning APIs and examples Transport data: production, APIs and utilisation Open Data Novel services Responsibility of the authorities Third parties Disruptions Forecasts Vehicle locations
  6. 7.6.2012 Digitransit: The Concept • Integrated real-time passenger services for

    multi-modal trips • Open APIs first: This is not a single app, this is an application and a foundation for more: next generation, third parties, etc. • Mobile first: Small screens set the design constraints • HTML5 first: Can wrap HTML5 into native app later • Regular customers first − A commuter shouldn't need to re-choose the destination every morning and evening.
  7. HTML5 mobile app • Open Data, Open API, Open Source

    • Leaflet • React, Relay, Fluxible • Webpack, CoffeeScript
  8. Tools for GraphQL • GraphiQL • graphql-java, graphql-js, graphql-python, PostGraphQL

    • React & Relay, Apollo Client • A hack in Haskell: dropbox/datagraph
  9. MQTT Example message payload (JSON): {"tsi":1431417982,"spd":5,"lat":60.17052,"long":24.94359,"dl":52 ..} MQTT topic structure:

    /hfp/journey/type/id/line/direction/headsign/start_time/ next_stop/geohash_level/geohash Example message topic: /hfp/journey/bus/67bf46c0/1055/1/Koskela/1105/ 1020169/4/60;24/19/74/03 Example subscriptions: /hfp/journey/# (all messages) /hfp/journey/+/+/1055/1/# (line 1055 outbound) /hfp/journey/+/+/+/+/+/+/+/60;24/19/# (geohash map rectangle)
  10. MQTT in JavaScript var mqtt = require('mqtt'); var client =

    mqtt.connect('mqtt://mqtt.hsl.fi'); client.on('connect', function () { client.subscribe('/hfp/journey/#'); // client.publish('presence', 'Hello mqtt'); }); client.on('message', function (topic, message) { var data = JSON.parse(message); });
  11. Conclusions 1. Consider how general purpose your API is 2.

    Consider ”Post-REST” such as GraphQL 3. Consider MQTT and topic structure for realtime

More Decks by Tuukka Hastrup

Other Decks in Technology