Line timetables for routes serving same bus stop in both directions not found

I discovered a bug in my app where I’m not accounting for routes that serve the same bus stop in both directions. A specific example I’ve found is route N89 at Slade Green Station.

Querying the timetable for the route at this bus stop returns a disambiguation result:
Endpoint - https://api.tfl.gov.uk/Line/n89/Timetable/490001252A

{
    "$type": "Tfl.Api.Presentation.Entities.TimetableResponse, Tfl.Api.Presentation.Entities",
    "disambiguation": {
        "$type": "Tfl.Api.Presentation.Entities.Timetables.Disambiguation, Tfl.Api.Presentation.Entities",
        "disambiguationOptions": [
            {
                "$type": "Tfl.Api.Presentation.Entities.Timetables.DisambiguationOption, Tfl.Api.Presentation.Entities",
                "description": "Erith Town Centre / Cross Street - Charing Cross Station",
                "uri": "/Line/n89/Timetable/490001252A/inbound"
            },
            {
                "$type": "Tfl.Api.Presentation.Entities.Timetables.DisambiguationOption, Tfl.Api.Presentation.Entities",
                "description": "Trafalgar Square / Charing Cross Stn - Erith Town Centre / Riverside",
                "uri": "/Line/n89/Timetable/490001252A/outbound"
            }
        ]
    }
}

Now querying one of the given URIs return a 404:
Request - https://api.tfl.gov.uk/Line/n89/Timetable/490001252A/inbound

{
    "$type": "Tfl.Api.Presentation.Entities.ApiError, Tfl.Api.Presentation.Entities",
    "timestampUtc": "2021-12-26T15:03:08.9300366Z",
    "exceptionType": "EntityNotFoundException",
    "httpStatusCode": 404,
    "httpStatus": "NotFound",
    "relativeUri": "/Line/n89/Timetable/490001252A/inbound",
    "message": "Resource not found: http://api:8001/Line/n89/Timetable/490001252A/inbound"
}

Is this a known issue or is there something I’m doing incorrectly?

Hi @nathanodong

Sorry for taking so long getting back to you. I was running down about a dozen different rabbit holes with this one.

It appears that the format of the URI returned by the disambiguation is incorrect. The correct way to do that call is:

https://api.tfl.gov.uk/Line/n89/Timetable/490001252A?direction=inbound &
https://api.tfl.gov.uk/Line/n89/Timetable/490001252A?direction=outbound

I’m raising a bug to look into why the disambig is doing this but feel free to amend your application to use the calls in the format above.

Thanks,
James

Bug ref: 58723

1 Like