Automatically selecting a journey planning service

7 Apr 2017 by Jonathan Raper

A journey plan with bus and train alternatives from Durham to Darlington using Traveline South East

We added a feature to our journey planning API: this automatically selects the most appropriate service provider depending on whether the journey is within, or outside of, London.

“Journey Planning” involves you specifying a “from” and a “to” location to receive back journey details including multiple alternatives, which may make use of multiple means of transport,┬áchanging between buses, or from bus to train for example. We provide this by integrating third┬áparty journey planning systems.

There is a choice of two:

Traveline South East‘s journey planner (service=southeast) will, despite the name, operate UK-wide, including doing a reasonable job of London.

Transport For London‘s journey planner (service=tfl) will only work for journeys in and around London but it generally works a little better when you look at some details e.g. support for routing around delays. Perhaps most importantly, TfL’s service responds faster.

Or you can leave out the ‘service’ parameter. The default is… a new thing. We’ll come on to that…

Actually these are the two which we have commercial arrangements with, for offering to you publicly. We did a similar integration for another service exclusively for one of our enterprise customers. We’re also prototyping an in-house journey planner. For the moment you can choose between tfl or southeast.

As with other areas of our API, we’ve worked hard to rationalise and reformat data we get from the underlying systems. In this case we’re providing you with a uniform interface regardless of which service you select. Your code to consume the data will look the same either way. This means you can even flip between the two dynamically.

We found ourselves recommending this dynamic approach to a few customers, with the following logic: Use service=tfl if your end user is doing a London journey (with both “from” and “to” location within TfL’s operating area) Use service=southeast if either your “from” and “to” location, or both, are not in London.
Selecting journeying planning service

Now there are a few interesting edge cases to TfL’s journey planning coverage. Specifying points outside of London, particularly major railway stations, can sometimes work. We’ve seen successful journey plans to destinations as far afield as Liverpool out of TfL’s journey planner. We’ve also occasionally seen ongoing transport details from the train stations at these destinations, but this is more rare. The coverage is too sporadic to be relied upon for general purpose requests. We find it better to fall back to Traveline South East for any location outside Greater London.

Sounding a bit complicated? Well that’s why we’ve now decided we should do this logic for you! If you simply leave off the ‘service’ parameter from requests, we will now select a service automatically based on whether your “from” and “to” location is in London each time.

If you want to check which selection we’ve made, see the “source” response field.

If you don’t want this behaviour, simply specify the service parameter explicitly to override it.

In general the feature means that you no longer need to concern yourself with choosing which service to use. We’ll make sure your application gets the best journey planning response available for your given query. Leave off the ‘service’ parameter to give it a try!

See our journey planning documentation for more details.