A basic warapper around TransportAPI (http://transportapi.com/)
How to use it:
Install TransportAPI
npm install transport-api
Require TransposrtAPI
var TransportAPI = require('TransportAPI');
Instantiate an instance of TransposrtAPI. You'll need to provide options specifying your api key and app ID from transportAPI
var options = {
APIID: process.env.TransportAPI_API_ID,
APIKey: process.env.TransportAPI_API_KEY
},
transportapi = new TransportAPI(options);
Make a call to the API using the LiveBusDepartures.
The LiveBusDepartures function calls to the http://transportapi.com/v3/uk/bus/stop/{atcocode}/live[.format]?{group=} endpoint.
var options = {
group: "route"
};
transportapi.LiveBusDepartures(atcocode, options, function (err, res, data) {
if (err) throw err;
log('res: ' + util.inspect(res));
log('data: ' + util.inspect(data));
});
The BusDepartures function calls to the http://transportapi.com/v3/uk/bus/stop/{atcocode}/{date}/{time}/timetable[.format]?{group=} endpoint.
var options = {
group: "route"
};
transportapi.BusDepartures(atcocode, options, function (err, res, data) {
if (err) throw err;
log('res: ' + util.inspect(res));
log('data: ' + util.inspect(data));
});
The NearbyBusStops function calls to the http://transportapi.com/v3/uk/bus/stops/near[.format]?{lon=&lat=}[&page=][&rpp=] endpoint.
var options = {
lon: "-0.0938",
lat: "51.5207",
page: 3,
rpp: 8
};
transportapi.BusDepartures(options, function (err, res, data) {
if (err) throw err;
log('res: ' + util.inspect(res));
log('data: ' + util.inspect(data));
});
The BusStopsInAboundingBox function calls to the http://transportapi.com/v3/uk/bus/stops/bbox[.format]?{minlon=&minlat=&maxlon=&maxlat=}[&page=][&rpp=] endpoint.
var options = {
minlon: "-0.0938",
minlat: "51.5207",
maxlon: "-0.074",
maxlat: "51.5286",
page: 3,
rpp: 8
};
transportapi.BusStopsInAboundingBox(options, function (err, res, data) {
if (err) throw err;
log('res: ' + util.inspect(res));
log('data: ' + util.inspect(data));
});
- NearbyTrainStations(options, callback)
- StationsInAboundingBox(options, callback)
- StationsServedbyanOperator(station_code, options, callback)
- ScheduledStationDepartures(station_code, date, time, options, callback)
- LiveStationDepartures(station_code, options, callback)
- LiveStationArrivals(station_code, options, callback)
- ScheduledService(service_code, station_code, date, time, options, callback)