transilien-api
v2.0.0
Published
An asynchronous client library for the Transilien API.
Downloads
12
Readme
Transilien API 1.0.0
An asynchronous client library for the real time Transilien API.
const TransilienApi = require('transilien-api');
const client = new TransilienApi({
basic_authorization: ''
});
client.nextDepartures(trainStation)
.then(console.log)
.catch(console.error);
Installation
npm install transilien-api
You can follow instructions here to get your access authorization.
const TransilienApi = require('transilien-api');
const client = new TransilienApi({
basic_authorization: '<basic token>'
});
Requests
With endpoints
You now have the ability to make GET requests against the API via the convenience methods.
client.get(path, params);
You simply need to pass the endpoint and parameters to one of convenience methods. Take a look at the documentation site to reference available endpoints.
client.get(`/gare/87758011/depart/87384008/`);
With client methods
You can use the defined client methods to call endpoints.
client.nextDeparturesToDestination(87758011, 87384008);
Promises
The request will return Promise.
client.nextDeparturesToDestination(87758011, 87384008)
.then(data => console.log(data))
.catch(function (e) {
throw e;
});