pgrimaud / ratp-api-rest

This project turnkey is distributed as a middleware to expose RATP realtime data as REST resources
MIT License
85 stars 15 forks source link

Schedules disambiguation issue #6

Closed chrism closed 6 years ago

chrism commented 6 years ago

Hi,

I've been struggling to get the schedules for RER lines with multiple destinations.

For RER A (only one line) this request

https://api-ratp.pierre-grimaud.fr/v3/schedules/rers/A/chatou+croissy/R

returns

{
    "result": {
        "schedules": [
            {
                "code": "QIWI",
                "message": "13:42",
                "destination": "Marne-la-Vallee Chessy"
            },
            {
                "code": "QIWI",
                "message": "13:53",
                "destination": "Marne-la-Vallee Chessy"
            },
            {
                "code": "QIWI",
                "message": "14:01",
                "destination": "Marne-la-Vallee Chessy"
            },
            {
                "code": "QIWI",
                "message": "14:13",
                "destination": "Marne-la-Vallee Chessy"
            },
            {
                "code": "QIWI",
                "message": "14:21",
                "destination": "Marne-la-Vallee Chessy"
            },
            {
                "code": "QIWI",
                "message": "14:33",
                "destination": "Marne-la-Vallee Chessy"
            }
        ]
    },
    "_metadata": {
        "call": "GET /schedules/rers/A/chatou+croissy/R",
        "date": "2018-02-15T13:38:30+01:00",
        "version": 3
    }
}

whereas when including the id parameter in the request

https://api-ratp.pierre-grimaud.fr/v3/schedules/rers/A/chatou+croissy/R?id=77

response

{
    "result": {
        "schedules": [
            {
                "destination": "St Germain en Laye"
            },
**snip**
            {
                "destination": "St Germain en Laye"
            }
        ]
    },
    "_metadata": {
        "call": "GET /schedules/rers/A/chatou+croissy/R",
        "date": "2018-02-15T13:32:11+01:00",
        "version": 3
    }
}

For RER A this is fine as without the id the schedule returns correctly.

However, for RER C it is necessary to include the id and the response and therefore the response is always a list of destinations without any time.

request with id

https://api-ratp.pierre-grimaud.fr/v3/schedules/rers/C/dourdan/R?id=1029

response

{
    "result": {
        "schedules": [
            {
                "destination": "Invalides"
            },
**snip**
            {
                "destination": "Invalides"
            }
        ]
    },
    "_metadata": {
        "call": "GET /schedules/rers/C/dourdan/R",
        "date": "2018-02-15T13:33:05+01:00",
        "version": 3
    }
}

without id results with an error response

https://api-ratp.pierre-grimaud.fr/v3/schedules/rers/C/dourdan/R

response

{
    "result": {
        "code": 400,
        "message": "Ambiguous Line"
    },
    "_metadata": {
        "call": "GET /schedules/rers/C/dourdan/R",
        "date": "2018-02-15T13:44:42+01:00",
        "version": 3
    }
}

Have I missed something here, or is this a bug with the API?

Many thanks for the excellent service.

pgrimaud commented 6 years ago

Hi @chrism,

Unfortunately, I can't fixed it... the problem comme from the official RATP API.

RER C is not managed by the RATP. So their API is not working properly. Same problem with RER A, which is half managed by RATP.

Sorry about that