api.tfl.gov.uk/StopPoint/{ids} fails for some stops


#1

I’ve noticed that /StopPoint/{ids} fails for a small number of bus stops.

E.g., https://api.tfl.gov.uk/StopPoint/490011309S

The server returns a 404 response and a JSON payload like …

{
   "relativeUri" : "/StopPoint/490011309S",
   "$type" : "Tfl.Api.Presentation.Entities.ApiError, Tfl.Api.Presentation.Entities",
   "exceptionType" : "EntityNotFoundException",
   "httpStatus" : "NotFound",
   "timestampUtc" : "2018-12-19T07:37:37.5918085Z",
   "message" : "The following stop point is not recognised: 490011309S",
   "httpStatusCode" : 404
}

Just a heads up :wink:


#2

Out of interest, where did you get 490011309S from?


#3

490011309S shows up in the response to …

https://api.tfl.gov.uk/line/244/arrivals

… and other routes that use the stop (e.g., 486).

I don’t know if it’s relevant, but this stop is very close to a bus terminal (of sorts). The 244 starts and ends it’s route here and there’s a parking area where they hang around for a bit before leaving.

   {
      "operationType" : 1,
      "lineName" : "244",
      "currentLocation" : "",
      "naptanId" : "490011309S",
      "modeName" : "bus",
      "destinationNaptanId" : "",
      "timestamp" : "2018-12-19T10:03:48.6451506Z",
      "stationName" : "Queen Elizabeth Hospital / West Entrance",
      "lineId" : "244",
      "$type" : "Tfl.Api.Presentation.Entities.Prediction, Tfl.Api.Presentation.Entities",
      "destinationName" : "Abbey Wood",
      "bearing" : "222",
      "id" : "434034506",
      "direction" : "outbound",
      "timing" : {
         "$type" : "Tfl.Api.Presentation.Entities.PredictionTiming, Tfl.Api.Presentation.Entities",
         "source" : "2018-12-18T19:12:20.825Z",
         "sent" : "2018-12-19T10:03:48Z",
         "read" : "2018-12-19T10:03:45.865Z",
         "insert" : "2018-12-19T10:04:03.471Z",
         "received" : "0001-01-01T00:00:00Z",
         "countdownServerAdjustment" : "-00:00:17.5624217"
      },
      "platformName" : "H4",
      "timeToLive" : "2018-12-19T10:28:10Z",
      "towards" : "Blackheath, Eltham or Woolwich",
      "expectedArrival" : "2018-12-19T10:27:40Z",
      "vehicleId" : "YX61BXY",
      "timeToStation" : 1432
   },

#4

Interesting.

I had a similar-looking problem because the live “countdown” feed was inserting control characters (CR and/or LF) into the output sometimes so I couldn’t use the incoming data without cleaning it.

But I’m also sure I’ve seen this exact bus-stop location be problematic before, but I can’t find any record of it in my notes.

Of course, you have already discovered the work-around…


#5

Err … what’s the workaround? Currently I’m just dealing with the 404 response and displaying an “Oops …” message.


#6

I’m wondering if the stop ID should be 490011307S

https://api.tfl.gov.uk/StopPoint/490011307S

> egrep 490011307S Stops.csv 
"490011307S","58523","",,"Queen Elizabeth HospWest Entr","","","","---","","---","","--","","->S","","S","E0034323","Charlton","London","","","","","","0","U",542539,177314,0.0511142807,51.4768396285,"BCT","MKD","OTH","","","","082","2012-01-22T18:40:03","2015-10-19T08:51:03",5,"rev","act"

There’s no 490011309S in the (admittedly old) naptan data that I have.


#7

490011307S is the alighting-only termination point for routes 291 & 469. My assumption would be that 490011309S is actually the bus stand where buses from those two routes, together with the 244, wait during turnaround. I would guess that /Line/Arrivals is not filtering out non-public stops correctly (or at all)


#8

@nickp - thanks. This does sound plausible. I was wondering if it might be something to do with the stop being the end of the route.

The same stop (490011309S) also turns up in the arrivals data for the 486 which doesn’t actually terminate there, but does stop at the West Entrance.

Using …

https://api.tfl.gov.uk/line/{route}/Route/Sequence/{direction}

… to get a list of stops for the 244 and 486 in both directions, I get …

244 inbound  490011307H3 : Queen Elizabeth Hospital / West Entrance
244 outbound 490011309Z  : Queen Elizabeth Hospital / West Entrance

486 inbound  490011307H3 : Queen Elizabeth Hospital / West Entrance
486 outbound 490011309Z  : Queen Elizabeth Hospital / West Entrance

So the arrival data seems to be at odds with the route information in so much as it includes a stop ID that’s not listed as part of the route. In this case it looks like the arrival data should include 490011309Z rather than 490011309S

https://api.tfl.gov.uk/StopPoint/490011309Z works as expected.