Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@nederlandse-spoorwegen/travel-information-api
Advanced tools
Readme
The NS API package provides a high level wrapper for the NS travel information API.
npm install @nederlandse-spoorwegen/travel-information-api
Clone the repository and run the following commands:
npm install
npm run dev
A development server is now running allowing you to test your changes directly on your machine.
For more documentation about parameters and responses please refer to the NS developer portal
All errors are returned directly to the user and are not handled by the wrapper.
Create a new api instance using your key and optional base url. By default the base url is correctly set and you do not need to specify it.
const api = new NsApi("YourKey")
All calls return a Promise.
Get a list of departure by station code or UIC code. Note that when both a station code and uic code have been specified the station code has the higher priority.
const departures = api.departures()
const params = {
station: "UT", // Utrecht Centraal
uicCode: "8400058" // Amsterdam Centraal
}
departures.list(params)
.then((result) => {
// Handle successful response
})
.catch((error) => {
// Handle error
})
Get a list of all disruptions.
const disruptions = api.disruptions()
const params = {
type: "storing"
actual: false,
lang: "en"
}
disruptions.list(params).then((result) => {
})
Get a list of disruptions by providing a station code.
disruptions.byStation("UT").then((result) => {
})
Get a specific disruptions by using an id.
disruptions.byId("SomeId").then((result) => {
})
Get information about journey fares and discounts. Dates should us the following format: 'yyyy-MM-dd'
const prices = api.prices()
const params = {
fromStation: "ASD", // Amsterdam Centraal
toStation: "UT", // Utrecht Centraal
plannedFromTime: "2018-10-14",
};
prices.get(params).then((result) => {
})
Information about stations.
const stations = api.stations()
stations.list().then((result) => {
})
Returns travel advice information.
const trips = api.trips();
const params = {
fromStation: "ASD", // Amsterdam Centraal
toStation: "UT", // Utrecht Centraal
};
trips.get(params).then((result) => {
})
FAQs
A wrapper for the NS travel information API.
The npm package @nederlandse-spoorwegen/travel-information-api receives a total of 7 weekly downloads. As such, @nederlandse-spoorwegen/travel-information-api popularity was classified as not popular.
We found that @nederlandse-spoorwegen/travel-information-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.