Skip to content

Watje/ns-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

NS API

An API for talking to the NS (Dutch railways) API interface written in Java. The NS is using a mix between Dutch and English terms in their API. This reflects back to the Java implementation. The preferred language is English but some Dutch terms show up. Javadoc is English. When Dutch terms are used a translation is provided

Usage

To use the NS api you need to register an account with the NS. You can apply for an account at NS API.

You will receive a username and password. To use the Java api, you initialize the NsApi object:

NsApi nsApi = new NsApi(username, password);

Next step is to create a request, eg a 'actuele vertrektijden' request to get the current departures:

ApiRequest<ActueleVertrekTijden> request = RequestBuilder.getActueleVertrektijden(stationName)

To do the actual request, you call getApiResponse with your request:

ActueleVertrekTijden vertrekTijden = nsApi.getApiResponse(request); 

A new immutable object ActueleVertrekTijden is created containing the result of the API call.

All classes are immutable and thread safe.

Maven

Version 1.0 of this api is available in the central maven repository:

<dependency>
  <groupId>nl.pvanassen</groupId>
  <artifactId>ns-api</artifactId>
  <version>1.0</version>
</dependency>

Code borrowing

For parsing the XML I made use of the code found in this article: http://blog.another-d-mention.ro/programming/the-simplest-way-to-parse-xml-in-java/

License

The code is licensed under the Apache License.

About

An API for talking to the NS (Dutch railways) API interface written in Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%