fvdm / nodejs-ns-api

Unofficial NodeJS module for Nederlandse Spoorwegen API

Home Page:https://www.npmjs.com/package/ns-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Response error: API_KEY_NOT_ALLOWED_TO_PLAN_DOOR_TO_DOOR

gevgeny opened this issue · comments

Trying to use some of the lib's methods like getAllStations all getTrips, but get this: error

{
    "timestamp": "2021-05-08T08:27:36+0000",
    "path": "/api/v3/trips",
    "message": "Bad Request",
    "requestId": "6bbad54b-db8c-43e0-8f33-844f3eec3dc6",
    "code": 400,
    "errors": [
        {
            "message": "Met deze API key mogen geen deur-tot-deur adviezen opgevraagd worden 🙁",
            "type": "API_KEY_NOT_ALLOWED_TO_PLAN_DOOR_TO_DOOR",
            "lang": "nl"
        }
    ]
}

This is strange because this key works with https://gateway.apiportal.ns.nl/places-api/v2/places api.
Any ideas?

I believe you need to add the 'NS App' product to your API account. It's been a while since I created my account, but I remember needing to sign up to different products to access certain endpoints.

https://apiportal.ns.nl/products/NsApp

@fvdm hmm. I think it is already added.
image
And my profile:
image

Alright, I will check it out and add the Places API in the process.

I tried to make the call via vanilla api (https://gateway.apiportal.ns.nl/reisinformatie-api/api/v3/trips) and responses with the same error, so looks like it is not the lib issue, or I am doing something wrong :)

Can you tell me the request parameters you are using?

I just ran the CI test and there it went fine. Except for the Prices API which has changed.

Sure.

https://gateway.apiportal.ns.nl/reisinformatie-api/api/v3/trips?
destinationLat=52.0413726539037&
destinationLng=4.34035386746875&
dateTime=2021-05-07T18:35:00&
originLat=52.3568339514312&
originLng=4.82095942954253

I tried to add names but it does not help:

https://gateway.apiportal.ns.nl/reisinformatie-api/api/v3/trips?
destinationLat=52.0413726539037&
destinationLng=4.34035386746875&
dateTime=2021-05-07T18:35:00&
originLat=52.3568339514312&
originLng=4.82095942954253&
destinationName=Patentlaan 1, 2288EE, Rijswijk&
originName=Jan Muschstraat, Amsterdam

The names are for your own reference to be included in the response. They have no effect on the query.

I get the same error when I use the coordinates. It works fine when I use fromStation and toStation. I think the more detailed routes need a different subscription. To find out more I have send them an email.

Hi @gevgeny, I got a reply from NS. Door-to-door access is not yet available to external developers.

Until it is I think the Google Maps Directions API with the mode=transit parameter is better suited for this.

Hi @gevgeny. Got the response too, not available for users.