How do I plan a journey using StopPoint ids?

Originally posted by daain

I’m trying to narrow routes down to very particular ones based on traveller preferences, and normally filtering by modes gets me to the right one, but not always.

So as a second option I wanted to use ‘via’, but it seems to be a bit too limited. Let me illustrate the point with an example. In this particular case between two given postcodes the normal route returns bus 242, but as an alternative I’m trying to force the journey planner to return one with route 48. Please have a look at the responses for these two requests:

  1. https://api.tfl.gov.uk/journey/journeyresults/E9%207AL/to/E1%206JJ?mode=bus&via=Hackney%20(London),%20St%20Thomas's%20Square

  2. https://api.tfl.gov.uk/journey/journeyresults/E9%207AL/to/E1%206JJ?mode=bus&via=-0.05527733293,51.54206348122

In the first case I get a disambiguation result and in the second case specifying the lon/lat value just fails. So there’s no way to specify a valid via going through this bus stop.

Maybe it’s just a bug with the lon/lat method, but in general it would be great if it was possible to specify points using ids, just as the online journey planner accepts viaid in the URL.

Hi @daain, you’re right that the from/to supports stop point ids, but I’ll check for you about via. It seems that it should be possible to specify this as an id, postcode, lat/lon or free text. If it doesn’t support one of those things, I can add it as a feature request for you.

I agree that the documentation can be improved, especially around responses. We have this task on our backlog.

Also, yes, I’ll admit the JP response changing types is ugly, we will look into that – the RESTful way would be a redirect to a Disambiguation endpoint I think. But a way that will break things less for devs now that it’s in the wild might be to have a single return type that can have a Disambiguation property when needed.

From daiin

Apologies, the right ID / URL is actually this for the southbound service: https://api.tfl.gov.uk/journey/journeyresults/E9%207AL/to/E1%206JJ?mode=bus&via=490012462S

And: https://tfl.gov.uk/bus/stop/490012462S/st-thomass-square/?lineId=48

It still doesn’t work though :frowning_with_open_mouth:

The Journey Planner API now correctly supports a Naptan for the via option:

https://api.tfl.gov.uk/journey/journeyresults/E9%207AL/to/E1%206JJ?mode=bus&via=490012462S

Goes via St Thomas’s Square as expected:

$ curl "https://api.tfl.gov.uk/journey/journeyresults/E9%207AL/to/E1%206JJ?mode=bus&via=490012462S" | jq . | grep summary
        "summary": "Walk to Holcroft Road",
        "summary": "277 bus to St Thomas's Square",
        "summary": "55 bus or 48 bus to Shoreditch Church",
        "summary": "Walk to E1 6JJ",
        "summary": "Walk to Terrace Road",
        "summary": "277 bus to St Thomas's Square",
        "summary": "55 bus or 48 bus to Shoreditch Church",
        "summary": "Walk to E1 6JJ",
        "summary": "Walk to Terrace Road",
        "summary": "277 bus to St Thomas's Square",
        "summary": "55 bus or 48 bus to Shoreditch Church",
        "summary": "Walk to E1 6JJ",
        "summary": "Walk to E1 6JJ",
1 Like