Searching Bus StopPoint code for use with arrival search

Building a Discord Chatbot command which can get bustime arrivals for a searched bus stop.

Using the search endpoint and filtering by bus mode, I can get the bus stop ID which appears incorrect because when i run that into the StopPoint/{query}/Arrivals endpoint, it returns empty data. Why might it be doing this, am I using an incorrect endpoint??

Example using from query ‘colliers wood station’

age: 0
api-entity-payload: StopPoint
cache-control: public, must-revalidate, max-age=302400, s-maxage=604800
content-encoding: gzip
content-length: 303
content-type: application/json; charset=utf-8
date: Fri, 23 Jun 2023 08:50:29 GMT
server: cloudflare
via: 1.1 varnish
x-api: StopPoint
x-aspnet-version: 4.0.30319
x-backend: api
x-cache: MISS
x-cacheable: Yes. Cacheable
x-frame-options: deny
x-operation: StopPoint_SearchByPathQueryQueryModesQueryFaresOnlyQueryMaxResultsQueryLines
x-proxy-connection: unset
x-ttl: 604800.000
x-ttl-rule: 0
x-varnish: 791231839

{
    "$type": "Tfl.Api.Presentation.Entities.SearchResponse, Tfl.Api.Presentation.Entities",
    "query": "colliers wood",
    "total": 2,
    "matches": [{
        "$type": "Tfl.Api.Presentation.Entities.MatchedStop, Tfl.Api.Presentation.Entities",
        "icsId": "1000055",
        "topMostParentId": "940GZZLUCSD",
        "modes": ["tube", "bus"],
        "zone": "3",
        "id": "940GZZLUCSD",
        "name": "Colliers Wood Underground Station",
        "lat": 51.41816,
        "lon": -0.178086
    }, {
        "$type": "Tfl.Api.Presentation.Entities.MatchedStop, Tfl.Api.Presentation.Entities",
        "icsId": "1014648",
        "topMostParentId": "490G00014648",
        "modes": ["bus"],
        "id": "490G00014648",
        "name": "Colliers Wood United Football Club",
        "lat": 51.421264,
        "lon": -0.253344
    }]
}

using the “id” from the 2md result:

age: 0
api-entity-payload: Prediction
cache-control: public, must-revalidate, max-age=30, s-maxage=60
content-encoding: gzip
content-length: 22
content-type: application/json; charset=utf-8
date: Fri, 23 Jun 2023 08:52:04 GMT
server: cloudflare
via: 1.1 varnish
x-api: StopPoint
x-aspnet-version: 4.0.30319
x-backend: api
x-cache: MISS
x-cacheable: Yes. Cacheable
x-frame-options: deny
x-operation: StopPoint_ArrivalsByPathId
x-proxy-connection: unset
x-ttl: 60.000
x-ttl-rule: 0
x-varnish: 1918256092

[]

Hello, and welcome to the forum!

StopPoints are a hierarchy. In other words, a StopPoint can have other StopPoints as children, which can in turn have other StopPoints as children.

For example, you might have a transport hub that includes a bus station. And the bus station contains several individual bus stops.

To retrieve StopPoint arrivals, you will need to provide the ID of a specific stop (not a hub, bus station, etc.).

If you take a look at the StopPoint Search response, you’ll see that it returns groups of bus stops, rather than individual bus stops. You can tell that 490G00014648, for example, is a group because the fourth character of the ID is the letter ‘G’ (Group). In IDs of individual bus stops, the fourth character will be the digit ‘0’.

By making a request to https://api.tfl.gov.uk/StopPoint/490G00014648 and looking at the children property, you can see the hierarchy, which I will simplify as:

  • 490G00014648
    • 490014648N
    • 490014648S

In other words, 490G00014648 is a group of two bus stops. 490014648N and 490014648S are the individual bus stops (fourth character is a ‘0’).

Once you have the ID of an individual bus stop, you can then make a request like the following to retrieve arrivals at that stop:
https://api.tfl.gov.uk/StopPoint/490014648N/Arrivals

I hope this helps. Please let me know if you have any further questions.

1 Like

There are situations where it would be useful to be able to pick up arrivals for the whole hub, or perhaps from all stops within a small radius. The screen at Edmonton Green Bus Station does this so there must be some way of doing this.

To take an example, if you are at Wood Green Station wanting Stamford Hill you have the 67 and the 243 from different stops. (Journey Planner will tell you to “walk to Lordship Lane” for the 67 stop in High Road, which is a bit odd if you are standing in Lordship Lane at the time, but that’s another story!)

hi @mjcarchive

If you’re referring to the bus station signage (like Archway below), these are actually manually created with the calls to Countdown for each individual stop configured within the template for that bus station.

1 Like

Ah, bespokery. It would be nice to have the ability to specify multiple stops in one call, though I’m not suggesting it would necessarily be worth the scarce resource needed. Yesterday I could see when the 121 was coming in Enfield Town but not (because their stop has no screen) the 456 or W9, which are good options for me. Mind you, I was out of data anyway…

They sometimes show their URLs when they lose their network connections… :slight_smile:

https://countdown.digisign.tfl.gov.uk/sign/957/yor3l

I quite like our version of them
RTI and press “live bus data” to toggle between live and timetable.

and maps of course!

That’s reminded me … at one time, if there were several buses that could be used for a section of a journey, JP would list all of them (eg “take 149, 388, 35 or 47 bus to Liverpool Street”. Recently I’ve only ever seen only a single bus listed. The result is that I’m standing at the stop, waiting specifically for a 149 and letting several 388s go past even though I could have got the 388 if it had been listed as it previously was. The alternatives are useful information, especially if the specific bus gets held up (or more annoylngly, gets “told to wait” or even turned round) a stop or two earlier,

1 Like

Thank you for your feedback. Yes, we unfortunately had to turn off line bundling (this also affects Tube where we used to say things like “Take the Circle line or District line”) as this was not compatible with live data.

However, we will see if there is any way we can bring this kind of functionality back whilst retaining live data.

1 Like