How do I get query Routes for a Hub?

Hiya, I seem to be struggling with the StopPoint endpoint for a hub. I’m searching for a bus stop here: https://api.tfl.gov.uk/StopPoint/Search?query=Waterloo&stopTypes=NaptanBusStop

My aim is to then get the routes which stop at that bus stop. This works fine for most bus stops - eg. https://api.tfl.gov.uk/StopPoint/490015048A/Route

But for hubs, nothing is returned from the endpoint - eg. https://api.tfl.gov.uk/StopPoint/HUBWHD/Route

Would it be possible to advise about what I’m doing wrong here? Thanks so much, and apologies if this has already been asked.

Basically a hub comprises by definition more than one StopPoint (as children) each of which you can find from the API. The API URL for your example is https://api.tfl.gov.uk/StopPoint/HUBWHD which produces a long list of “Entities” at that hub including bus routes. Using the API in this way is more complicated than searching for individual bus stops by name.

1 Like

Welcome @aurorum

The idea of a “hub” is a way of tying together cross-system places that have the same name.

Example of this are usually:

  • Bus station with a tube stop
  • Bus station with a national rail stop
  • Bus station with a DLR/tram stop
  • River boats with a national rail stop

HUBBDS Bond Street - Transport for London shows an example of Bond Street, which shows the three lines

and links to

Ah! I thought that it’d be too good to be true that I could find bus routes/directions from searching a stop with just two API requests. :slight_smile: Thanks so much for both your help!

You can get what I think you want quite easily by using the Legacy (Countdown) API. For example this URL will return all the stops named “Eden Street”, listing the Towards text for each stop and all the routes it serves.
https://countdown.api.tfl.gov.uk/interfaces/ura/instant_V1?StopAlso=1&ReturnList=StopCode2,StopPointName,Towards,LineName,DestinationName&StopPointName=eden street
You can still download very useful documentation from TfL.

1 Like

Thanks so much @misar - that’s a great help! However, I’m trying to allow users to search for a bus stop; filter out the routes which they’re interested in; and then get bus times for that (it’s just for messing around with an Alexa skill).

Am I correct in understanding that the Legacy endpoint still doesn’t really help me with that aim when it comes to hubs? For instance, if I search for “Waterloo” (which is the exact string that the /StopPoint/Search endpoint gives me when searching for Waterloo or variants of it), I still hit an error: https://countdown.api.tfl.gov.uk/interfaces/ura/instant_V1?StopAlso=1&ReturnList=StopCode2,StopPointName,Towards,LineName,DestinationName&StopPointName=Waterloo

Thanks again for your help!

I already told you that using the API to search on hubs is complicated. To see how complicated it becomes even for a “simple” search like your example (Waterloo) use the TfL website journey planner (Stations, stops & piers - Transport for London). The first of many options in the list it offers is plain “Waterloo”. Click on that one then select “Other transport options, Bus” to get another page (https://tfl.gov.uk/bus/stop/HUBWAT/waterloo) with a list of bus stops and their routes. If you want bus routes around Waterloo Station this hub (“HUBWAT”) is probably the one you need but that is not the same as searching for stops with names which include the word “Waterloo”.

What you want is really a bus stop search based on location (“Waterloo”). That is also easy with the Countdown API if you convert the location to a map reference. This URL will return the same data as before for all bus stops within 250m of Waterloo Station.
https://countdown.api.tfl.gov.uk/interfaces/ura/instant_V1?StopAlso=1&ReturnList=StopCode2,StopPointName,Towards,LineName,DestinationName&Circle=51.504359,-0.113742,250

1 Like