Bus stop hierarchies


#1

Journey Planner clearly uses some sort of hierarchy to group related stops when a user enters a search location. Looking at Bus stops search I would imagine that this is the topmostParentId value of StopPoint (e g 490G00008599 in the example above). Is there an easy way of accessing all such top level StopPoints, or alternatively all lower level StopPoints along with the parent StopPoint to which it belongs?

The obvious alternative place to look is the bus-stops.csv file but the parent codes are not there. The file does contain another possible hierarchy, in the form of the Stop_Area field. For the specific example above, this field has the value VA02. My suspicion is that although this may line up with the parent code (or whatever is used by Journey Planner) this may not always be the case but I would welcome clarification on this.

Why am I interested? My experience of using Journey Planner for bus is that at more complex locations it uses too fine a hierarchy (for example, one pair of stops at a junction) for advance journey planning purposes. I only care which of (say) half a dozen stops the bus serves at the end of the process. As things stand I may have to specify the stop(s) in advance, which could result at best in instructions that I do not need - “walk (from the stop I had to choose) to stop X…” and at worst could contribute to feasible journey options not appearing. I’m not convinced that one hierarchy is best for all purposes but before even contemplating attempting to construct something different it would make sense to have the full hierarchy visible.

I am new to contributing here but I hope this makes some sort of sense.


#2

Hi @mjcarchive you can use the StopPoint resource on the Unified API to search for and locate stop points, or join them to responses from the JourneyPlanner API e.g.

curl -s https://api.tfl.gov.uk/StopPoint/Search/kings | jq .
{
  "$type": "Tfl.Api.Presentation.Entities.SearchResponse, Tfl.Api.Presentation.Entities",
  "query": "kings",
  "total": 50,
  "matches": [
    {
      "icsId": "1000129",
      "modes": [
        "international-rail",
        "national-rail",
        "tube",
        "bus"
      ],
      "id": "HUBKGX",
      "name": "King's Cross & St Pancras International",
      "lat": 51.531683,
      "lon": -0.123538
    },

etc.

For more information see this blog article: Unified API: LoT - The Location of Things


#3

I’ve just realised I didn’t properly answer your question :slight_smile:

OK so to get all bus stops and their children, do this:

https://api.tfl.gov.uk/StopPoint/Mode/bus?page=1

You’ll have to keep paging through if you want to download all of the bus stops. The children/parents should all join up.


#4

Thanks, Tim. Only 36 pages to download! A tad on the tedious side but as it’s probably a one-off that’s fine.