{"id":21297496,"url":"https://github.com/fvdm/nodejs-ns-api","last_synced_at":"2025-07-11T18:32:30.010Z","repository":{"id":6196501,"uuid":"7427133","full_name":"fvdm/nodejs-ns-api","owner":"fvdm","description":"Unofficial NodeJS module for Nederlandse Spoorwegen API","archived":false,"fork":false,"pushed_at":"2024-04-02T16:32:40.000Z","size":307,"stargazers_count":20,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-07-10T01:51:23.156Z","etag":null,"topics":["nederlandse-spoorwegen-api","ns-api","trains","transit","unlicense","vertrektijden"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ns-api","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fvdm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://fvdm.com/donating/"}},"created_at":"2013-01-03T17:34:42.000Z","updated_at":"2025-01-19T23:19:28.000Z","dependencies_parsed_at":"2024-06-20T23:22:52.945Z","dependency_job_id":null,"html_url":"https://github.com/fvdm/nodejs-ns-api","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/fvdm/nodejs-ns-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-ns-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-ns-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-ns-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-ns-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fvdm","download_url":"https://codeload.github.com/fvdm/nodejs-ns-api/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvdm%2Fnodejs-ns-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264870602,"owners_count":23676275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nederlandse-spoorwegen-api","ns-api","trains","transit","unlicense","vertrektijden"],"created_at":"2024-11-21T14:37:45.096Z","updated_at":"2025-07-11T18:32:29.703Z","avatar_url":"https://github.com/fvdm.png","language":"JavaScript","funding_links":["https://fvdm.com/donating/"],"categories":[],"sub_categories":[],"readme":"# ns-api\n\nAccess public transit data from [Nederlandse Spoorwegen API](https://apiportal.ns.nl) with node.js\n\n[![Changelog](https://img.shields.io/npm/v/ns-api.svg?maxAge=3600)](https://github.com/fvdm/nodejs-ns-api/releases)\n[![Build Status](https://github.com/fvdm/nodejs-ns-api/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/fvdm/nodejs-ns-api/actions/workflows/node.js.yml)\n[![Coverage Status](https://coveralls.io/repos/github/fvdm/nodejs-ns-api/badge.svg?branch=master)](https://coveralls.io/github/fvdm/nodejs-ns-api?branch=master)\n\n\nTo use this module you need API access credentials,\nwhich you can request at [Here](https://apiportal.ns.nl/startersguide) (Dutch).\n\n* [Node.js](https://nodejs.org)\n* [package](https://www.npmjs.com/package/ns-api)\n* [API documentation](https://apiportal.ns.nl)\n\n\n## Example\n\n```js\nconst NSAPI = require ('ns-api');\nconst ns = new NSAPI ({\n  key: 'abc123',\n});\n\n// Output w/o limits\nfunction out (data) {\n  console.dir (data, {\n    depth: null,\n    colors: true,\n  });\n}\n\n// Get travel advise\nns.getTrips ({\n  fromStation: 'UT',\n  toStation: 'AMF',\n})\n  .then (out)\n  .catch (console.error)\n;\n```\n\n\n## Installation\n\n`npm i ns-api`\n\n\n## Configuration\n\nparam     | type   | default | description\n:---------|:-------|:--------|:-----------\nkey       | string |         | One of your API keys\n[timeout] | number | 8000    | Request time out in ms\n\n\n```js\nconst NSAPI = require ('ns-api');\nconst ns = new NSAPI ({\n  key: 'abc123',\n});\n```\n\n\n## Methods\n\nEach method returns a Promise, so make sure to catch the errors properly.\n\nWhen a method takes arguments they are only accepted in object notation.\nThis way the order no longer matters and it makes it easier to reuse them.\n\n```js\nmethodName ({ one, two });\n```\n\nI'm not going to outline to full possibilities of each method here,\nonly the parts that adjust the API response or make the request easier.\nRead the _API documentation_ links to find all available parameters that\neach method can take.\n\n\n## Reisinformatie\n\n### getAllStations\n\nList of all stations\n\n```js\nns.getAllStations()\n  .then (data =\u003e data.filter (station =\u003e station.land === 'NL'))\n  .then (data =\u003e console.table (data, ['code', 'stationType']))\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getAllStations)\n\n\n### getArrivals\n\nList of arrivals at a station. It requires a `station` or `uicCode`.\n\nparameter  | type           | description\n:----------|:---------------|:-----------\n[dateTime] | Date or string | Limit to starting time, will be converted to the right format\n\n```js\nns.getArrivals ({\n  dateTime: '2019-05-10',\n  station: 'UT',\n})\n  .then (data =\u003e console.table (data, ['name', 'origin', 'actualDateTime']))\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getArrivals)\n\n\n### getCalamities\n\nList of all current calamities\n\nparameter  | type           | description\n:----------|:---------------|:-----------\n[lang]     | string         | Text language\n\n```js\nns.getArrivals ({ lang: 'en' })\n  .then (console.log)\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getCalamities)\n\n\n### getDepartures\n\nList all departures at a station. It requires a `station` or `uicCode`.\n\nparameter  | type           | description\n:----------|:---------------|:-----------\n[dateTime] | Date or string | Limit to starting time, will be converted to the right format\n\n```js\nns.getDepartures ()\n  .then (console.log)\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getDepartures)\n\n\n### getDisruptions\n\nList of disruptions/maintenance.\n\nparameter  | type           | description\n:----------|:---------------|:-----------\n[actual]   | boolean        | Only return disruptions within 2 hours\n\n```js\nns.getDisruptions()\n  .then (data =\u003e console.table (data, ['titel']))\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getDisruptions)\n\n\n### getStationDisruption\n\nList of disruptions at a station\n\nparameter  | type           | description\n:----------|:---------------|:-----------\n[dateTime] | Date or string | Limit to starting time, will be converted to the right format\n\n```js\nns.getStationDisruption ({ dateTime: '2019-05-10' })\n  .then (data =\u003e console.table (data, ['titel']))\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getStationDisruption)\n\n\n### getDisruption\n\nGet details about one disruption\n\nparameter  | type           | description\n:----------|:---------------|:-----------\ntype       | string         | Disruption type\nid         | string         | Disruption object ID\n\n```js\nns.getDisruption ({\n  type: 'maintenance',\n  id: '7001000',\n})\n  .then (console.log)\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getDisruption)\n\n\n### getTrips\n\nGet a list of travel advises\n\nparameter  | type           | description\n:----------|:---------------|:-----------\n[dateTime] | Date or string | Limit to starting time, will be converted to the right format\n\n```js\nns.getTrips ({\n  dateTime: '2019-05-10 17:40',\n  fromStation: 'Amersfoort',\n  toStation: 'Den Haag',\n})\n  .then (console.log)\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getTrips)\n\n\n### getTrip\n\nGet a specific travel advise\n\nparameter   | type           | description\n:-----------|:---------------|:-----------\nctxRecon    | string         | Trip `ctxRecon` from [getTrips()](#getTrips)\n\n```js\nns.getTrip ({ ctxRecon: 'abc123' })\n  .then (console.log)\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getTrip)\n\n\n### getPrice\n\nGet pricing for travel between two stations.\n\nparameter   | type           | description\n:-----------|:---------------|:-----------\nfromStation | string         | Station name or ID\ntoStation   | string         | Station name or ID\n\n```js\nns.getPrices ({\n  fromStation: 'AMF',\n  toStation: 'Den Haag',\n})\n  .then (console.log)\n  .catch (console.error)\n;\n\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getPrice)\n\n\n### getJourney\n\nGet information about a specific journey.\nYou can find the `id` in the trip data from `getTrip()` at `trip.legs[].journeyDetail[].link.uri`.\nJust use that whole path.\n\n\nparameter | type   | description\n:---------|:-------|:-----------\nid        | string | Journey ID\n\n\n```js\nns.getJourney ({\n  id: 'HARP_S2S-1|3824|0|784|8052021',\n})\n  .then (console.log)\n  .catch (console.error)\n;\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/reisinformatie-api/operations/getJourneyDetail)\n\n\n## Places\n\n### placesList\n\nSearch for places.\nReturns an array.\n\nargument   | type   | description\n:----------|:-------|:-----------\nparameters | object | See API docs\n\n\n```js\nns.placesList ({\n  q: 'utrecht cs',\n});\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/Places-API/operations/places)\n\n\n### placesGet\n\nGet details about one place.\nReturns an object.\n\nparameter | type   | description\n:---------|:-------|:-----------\ntype      | string | Place type, ex: stationV2\nid        | string | Place ID, ex: AMF\n[lang]    | string | Response language\n\n\n```js\nns.placesGet ({\n  type: 'stationV2',\n  id: 'AMF',\n});\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/Places-API/operations/placesForType)\n\n\n### placesOvfiets\n\nGet a list of OV Fiets locations.\nReturns an array.\n\nparameter      | type   | description\n:--------------|:-------|:-----------\n[station_code] | string | Filter by station\n\n```js\nns.placesOvfiets ({\n  station_code: 'AMF',\n});\n```\n\n[API documentation](https://apiportal.ns.nl/docs/services/Places-API/operations/beschikbaarheid)\n\n\n## Unlicense\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \u003chttps://unlicense.org/\u003e\n\n\n## Author\n\n[Franklin](https://fvdm.com) | [Buy me a coffee](https://fvdm.com/donating)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvdm%2Fnodejs-ns-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffvdm%2Fnodejs-ns-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvdm%2Fnodejs-ns-api/lists"}