derhuerst / vbb-rest

An HTTP API for Berlin & Brandenburg public transport.
https://v6.vbb.transport.rest/
ISC License
130 stars 12 forks source link

How do you get stations on a departure? #21

Closed michaelcheers closed 6 years ago

michaelcheers commented 6 years ago

Say I get a departure:

https://vbb.transport.rest/stations/900000132500/departures

and I get:

[
    {
        "ref": "1|25705|1|86|8022018",
        "station": {
            "type": "station",
            "name": "Wiesenwinkel",
            "coordinates": {
                "latitude": 52.594429,
                "longitude": 13.380983
            },
            "id": "900000132500",
            "products": {
                "suburban": false,
                "subway": false,
                "tram": true,
                "bus": false,
                "ferry": false,
                "express": false,
                "regional": false
            }
        },
        "when": "2018-02-08T21:42:00+01:00",
        "direction": "Mitte, Am Kupfergraben",
        "line": {
            "type": "line",
            "name": "M1",
            "class": 4,
            "productCode": 2,
            "productName": "Str",
            "product": "tram",
            "mode": "train",
            "public": true,
            "id": "m1",
            "symbol": "M",
            "nr": 1,
            "metro": true,
            "express": false,
            "night": false
        },
        "remarks": [
            null,
            null
        ],
        "trip": 25705,
        "delay": 0
    }
]

How can I get what the next stations along the line are? In this case:

["900000132010", "900000132014"]

for trams towards "Rosenthal Nord".

I tried to use the refs generated but they don't seem to work. I used the following url:

https://vbb.transport.rest/journeys/legs/1%7C25705%7C1%7C86%7C8022018

and got

Cannot GET /journeys/legs/1%7C25705%7C1%7C86%7C8022018
derhuerst commented 6 years ago

Hey, thanks for using my API!

I've recently changed the structure of this repo. This is why you might be confused.

This weird way of looking up the next stations of a departure is due to the way the underlying VBB API works. My wrapping API cannot overcome these limitations.

Note that you also need to pass a lineName parameter. Basically take it from line.name from the departure and pass it into the route. This is also due to the terrible underlying VBB system.

Hope I could help you. Also, let me know if you stumble upon anything else that is intuitive or broken.