@onemedia/tfl-data-module
v1.9.4
Published
Fetches and translates data from the TFL Unified API.
Downloads
4
Readme
TFL Data Module
Fetches and translates data from the TFL Unified API.
const { Tube } = require('@onemedia/tfl-data-module');
const tubeData = new Tube({ url: process.env.TFL_API_URL, appId: process.env.TFL_APP_ID, appKey: process.env.TFL_APP_KEY });
const tubeStatus = await tubeData.status();
Table of Contents
Requirements
Paddington requires the following to run:
- [Node.js][node] 8+
- [npm][npm] (normally comes with Node.js)
Usage
tfl-data-module is installed via [npm][npm]:
npm install @onemedia/tfl-data-module
Then you can load the relevant module into your code with a require
call:
var { Tube, Bike } = require('@onemedia/tfl-data-module');
All modules are required to be instantiated with the API URL, APP_KEY and APP_ID. A timeout value in ms can also be passed in (although defaults to 10000).
const { Tube, Bike } = require('@onemedia/tfl-data-module');
const tubeData = new Tube({
url: process.env.TFL_API_URL,
appId: process.env.TFL_APP_ID,
appKey: process.env.TFL_APP_KEY
});
const bikeData = new Bike({
url: process.env.TFL_API_URL,
appId: process.env.TFL_APP_ID,
appKey: process.env.TFL_APP_KEY
});
Tube
tubeData.lines()
Retrieves all tube lines and their services.
tubeData.status()
Retrieves the line statuses of all Tube lines.
tubeData.findStationId(stationName)
Retrieves the TFL Station ID for a given station.
tubeData.findStationId(stationName)
Retrieves the TFL Station ID for a given station.
Bike
bikeData.searchStations(name)
Retrieves all BikePoints which contain the provided search term.
bikeData.getBikepointStats(pointId)
Retrieves information for a given BikePoint.
{
id: "BikePoints_810",
name: "Tate Modern, Bankside",
totalDocks: 30,
emptyDocks: 15,
availableBikes: 15
}