Bus arrivals near a postcode


#1

Complete newbie to the TFL API.

Is it possible to get upcoming arrivals/departures from bus stops near to a specified postcode ? I tried https://api.tfl.gov.uk/stoppoint/search/SE100ES/arrivals/?app_id={myid}&key={mykey}

but it returned “total”:0,“matches”:[]


#2

Something of this nature must be possible as Journey Planner permits postcode input. Not sure if it helps but the generated url is of this form
https://tfl.gov.uk/plan-a-journey/results?IsAsync=True&JpType=publictransport&InputFrom=N14+4LY

I would imagine that it used the centroid of (the addresses in) each postcode. That’s probably fine in built up areas as on average nationally each postcode represents about 14 addresses. Bear in mind though that postcodes are artificial creations designed fifty years ago to help Royal Mail and can be funny shapes! Also that it would be inadequate in rural areas as individual postcodes could cover quite a large area. So it might not work too well in parts of Enfield, Croydon, Bromley and so on. If the area is big enough the relevance of a stop near to a postcode would become pretty meaningless, i suspect.

The bigger and stranger looking the area covered, the harder it might be to define what you really want to do. Within 400m of the postcode centroid might actually exclude part of the postcode. Within 400m of the boundaries of the postcode would be very difficult to achieve, I would have thought.

Postcodes are a gift to statisticians, geographers and data linkers! I even did some of this best part of forty years ago to link geographical characteristics to areas sampled in the National Travel Survey. That hard slog could probably be done in hours rather than weeks now. I doubt that the original designers of the postcode system had any real inkling of how they would be used fifty years later. It is really a text book example of how what is basically administrative data set could be exploited by data linking and Open Data.


#3

Thanks for your reply. My ultimate objective is an Alexa skill. My own postcode covers six buildings, so if I publish, I’ll add your warning about accuracy.

But what I’m trying to do is to get departures from all nearby stops, not plan a journey. I may have several routes to my destination (leaving from stops in different directions) and I simply need the app to tell me which stop to walk to for the next departing bus.


#4

I told someone’s Alexa she was useless. Bit of thinking time, then - “Thanks for the feedback”.

I’ve made the point before that the geographical hierarchy on Journey Planner often does not work well as you end up having to choose between individual stops. Rather like you have to choose the platform at some stations for rail, even though trains to (say) Victoria might go from more than one.