new Twisto()
Create a Twisto instance
Methods
-
getBusStopsByLine(code, endpoint)
-
Return all stops by bus line
Parameters:
Name Type Description code
String Bus/Tramway code line
endpoint
String Bus/Tramway endpoint code
Returns:
Array of bus stops
- Type
- Array.<Object>
Example
var Twisto = require('twisto-node-api'); var twst = new Twisto(); twst.getLines() .then(function (lines) { return twst.getBusStopsByLine(lines[0].code, 'A'); }) .then(function (stops) { console.log('Stops: ', stops); }) .catch(function (err) { console.error('Error: ', err); });
-
getLines()
-
Return all lines of buses and tramways
Returns:
Array of lines buses and tramways
- Type
- Array.<Object>
Example
var Twisto = require('twisto-node-api'); var twst = new Twisto(); twst.getLines() .then(function (lines) { console.log('Lines: ', lines) }) .catch(function (err) { console.error('Error: ', err); });
-
getNextBusesByBusStop(reference)
-
Return next buses by bus line
Parameters:
Name Type Description reference
String Bus/Tramway stop reference
Returns:
Array of next buses
- Type
- Array.<Object>
Example
var Twisto = require('twisto-node-api'); var twst = new Twisto(); twst.getLines() .then(function (lines) { return twst.getBusStopsByLine(lines[0].code, 'A'); }) .then(function (stops) { return twst.getNextBusesByBusStop(stops[0].reference); }) .then(function (buses) { console.log('Buses: ', buses); }) .catch(function (err) { console.error('Error: ', err); });