Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tfl-api-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tfl-api-wrapper - npm Package Compare versions

Comparing version 1.6.0 to 1.6.1

CHANGELOG.md

2

dist/lib/accidentStats.js

@@ -29,3 +29,3 @@ "use strict";

Line.prototype.getAll = function (year) {
return this.sendRequest("/AccidentStats/" + year, {}, 'GET');
return this.sendRequest("/AccidentStats/".concat(year), {}, 'GET');
};

@@ -32,0 +32,0 @@ return Line;

@@ -30,3 +30,3 @@ "use strict";

BikePoint.prototype.getByID = function (id) {
return this.sendRequest("/BikePoint/" + id, {}, 'GET');
return this.sendRequest("/BikePoint/".concat(id), {}, 'GET');
};

@@ -33,0 +33,0 @@ /* Search for bike points by their name */

@@ -17,2 +17,7 @@ import TfLAPI from './tfl';

getByNaptanDay(naptanID: string, dayOfTheWeek: DaysOfTheWeek): Promise<ICrowding.Root>;
/**
* Get live crowding information for Naptan
* @param naptanID ID of the stop (eg. 940GZZLUASL)
*/
getLiveByNaptan(naptan: string): Promise<ICrowding.Live>;
}

@@ -29,3 +29,3 @@ "use strict";

Crowding.prototype.getAllByNaptan = function (naptanID) {
return this.sendRequest("/Crowding/" + naptanID, {}, 'GET');
return this.sendRequest("/Crowding/".concat(naptanID), {}, 'GET');
};

@@ -38,6 +38,13 @@ /**

Crowding.prototype.getByNaptanDay = function (naptanID, dayOfTheWeek) {
return this.sendRequest("/Crowding/" + naptanID + "/" + dayOfTheWeek, {}, 'GET');
return this.sendRequest("/Crowding/".concat(naptanID, "/").concat(dayOfTheWeek), {}, 'GET');
};
/**
* Get live crowding information for Naptan
* @param naptanID ID of the stop (eg. 940GZZLUASL)
*/
Crowding.prototype.getLiveByNaptan = function (naptan) {
return this.sendRequest("/Crowding/".concat(naptan, "/Live"), {}, 'GET');
};
return Crowding;
}(tfl_1.default));
exports.default = Crowding;

@@ -12,2 +12,8 @@ declare module Crowding {

}
interface Live {
dataAvailable: boolean;
percentageOfBaseline: number;
timeUtc: Date;
timeLocal: Date;
}
interface Root {

@@ -14,0 +20,0 @@ naptan: string;

@@ -42,3 +42,3 @@ "use strict";

Line.prototype.getAllStopPoints = function (line) {
return this.sendRequest("/Line/" + line + "/StopPoints", {}, 'GET');
return this.sendRequest("/Line/".concat(line, "/StopPoints"), {}, 'GET');
};

@@ -50,3 +50,3 @@ /**

Line.prototype.getAllByModes = function (modes) {
return this.sendRequest("/Line/Mode/" + tfl_1.default.arrayToCSV(modes), {}, 'GET');
return this.sendRequest("/Line/Mode/".concat(tfl_1.default.arrayToCSV(modes)), {}, 'GET');
};

@@ -63,6 +63,6 @@ /**

if (!startDate || !endDate) {
return this.sendRequest("/Line/" + tfl_1.default.arrayToCSV(lines) + "/Status", { detail: detail }, 'GET');
return this.sendRequest("/Line/".concat(tfl_1.default.arrayToCSV(lines), "/Status"), { detail: detail }, 'GET');
}
else {
return this.sendRequest("/Line/" + tfl_1.default.arrayToCSV(lines) + "/Status/" + tfl_1.default.convertDate(startDate) + "/to/" + tfl_1.default.convertDate(endDate), { detail: detail }, 'GET');
return this.sendRequest("/Line/".concat(tfl_1.default.arrayToCSV(lines), "/Status/").concat(tfl_1.default.convertDate(startDate), "/to/").concat(tfl_1.default.convertDate(endDate)), { detail: detail }, 'GET');
}

@@ -77,7 +77,7 @@ };

Line.prototype.getStatusByModes = function (modes, detail, severityLevel) {
return this.sendRequest("/Line/Mode/" + tfl_1.default.arrayToCSV(modes) + "/Status", { detail: detail, severityLevel: severityLevel }, 'GET');
return this.sendRequest("/Line/Mode/".concat(tfl_1.default.arrayToCSV(modes), "/Status"), { detail: detail, severityLevel: severityLevel }, 'GET');
};
/** Gets the timetable for a specified station on the give line with specified destination */
Line.prototype.getTimetableFromTo = function (line, from, to) {
return this.sendRequest("/Line/" + line + "/Timetable/" + from + "/to/" + to, {}, 'GET');
return this.sendRequest("/Line/".concat(line, "/Timetable/").concat(from, "/to/").concat(to), {}, 'GET');
};

@@ -92,3 +92,3 @@ /**

Line.prototype.getTimetableFromStation = function (line, NaPTANID, direction) {
return this.sendRequest("/Line/" + line + "/Timetable/" + NaPTANID, { direction: direction }, 'GET');
return this.sendRequest("/Line/".concat(line, "/Timetable/").concat(NaPTANID), { direction: direction }, 'GET');
};

@@ -103,3 +103,3 @@ /** Get the list of arrival predictions for given line ids based at the given stop

if (direction === void 0) { direction = 'all'; }
return this.sendRequest("/Line/" + tfl_1.default.arrayToCSV(ids) + "/Arrivals/" + NaptanID, { direction: direction, destinationStationId: destinationStationId }, 'GET');
return this.sendRequest("/Line/".concat(tfl_1.default.arrayToCSV(ids), "/Arrivals/").concat(NaptanID), { direction: direction, destinationStationId: destinationStationId }, 'GET');
};

@@ -111,3 +111,3 @@ /**

Line.prototype.getDistruptionsByID = function (ids) {
return this.sendRequest("/Line/" + tfl_1.default.arrayToCSV(ids) + "/Disruption", {}, 'GET');
return this.sendRequest("/Line/".concat(tfl_1.default.arrayToCSV(ids), "/Disruption"), {}, 'GET');
};

@@ -114,0 +114,0 @@ /**

@@ -37,3 +37,3 @@ "use strict";

if (count === void 0) { count = -1; }
return this.sendRequest("/Mode/" + mode + "/Arrivals", { count: count }, 'GET');
return this.sendRequest("/Mode/".concat(mode, "/Arrivals"), { count: count }, 'GET');
};

@@ -40,0 +40,0 @@ return Mode;

@@ -29,3 +29,3 @@ "use strict";

Occupancy.prototype.getBikePointByIDs = function (ids) {
return this.sendRequest("/Occupancy/BikePoints/" + tfl_1.default.arrayToCSV(ids), {}, 'GET');
return this.sendRequest("/Occupancy/BikePoints/".concat(tfl_1.default.arrayToCSV(ids)), {}, 'GET');
};

@@ -37,3 +37,3 @@ /**

Occupancy.prototype.getCarkParkByID = function (id) {
return this.sendRequest("/Occupancy/CarPark/" + id, {}, 'GET');
return this.sendRequest("/Occupancy/CarPark/".concat(id), {}, 'GET');
};

@@ -45,3 +45,3 @@ /**

Occupancy.prototype.getChargeConnectorByID = function (id) {
return this.sendRequest("/Occupancy/ChargeConnector/" + id, {}, 'GET');
return this.sendRequest("/Occupancy/ChargeConnector/".concat(id), {}, 'GET');
};

@@ -48,0 +48,0 @@ /**

@@ -35,3 +35,3 @@ "use strict";

Road.prototype.getByID = function (ids) {
return this.sendRequest("/Road/" + tfl_1.default.arrayToCSV(ids), {}, 'GET');
return this.sendRequest("/Road/".concat(tfl_1.default.arrayToCSV(ids)), {}, 'GET');
};

@@ -45,3 +45,3 @@ /**

Road.prototype.getStatusByID = function (ids, startDate, endDate) {
return this.sendRequest("/Road/" + tfl_1.default.arrayToCSV(ids) + "/Status", {
return this.sendRequest("/Road/".concat(tfl_1.default.arrayToCSV(ids), "/Status"), {
startDate: tfl_1.default.convertDate(startDate),

@@ -70,3 +70,3 @@ endDate: tfl_1.default.convertDate(endDate)

Road.prototype.getAllDisruptionsByID = function (ids, stripContent) {
return this.sendRequest("/Road/all/Disruption/" + tfl_1.default.arrayToCSV(ids), {
return this.sendRequest("/Road/all/Disruption/".concat(tfl_1.default.arrayToCSV(ids)), {
stripContent: stripContent

@@ -73,0 +73,0 @@ }, 'GET');

@@ -94,3 +94,2 @@ import TfLAPI from './tfl';

* @param output If set to "web", a 302 redirect to relevant website bus stop page is returned. All other values are ignored.
* @returns ENGLISH > FRENCH
*/

@@ -97,0 +96,0 @@ getBySMSCode(smsID: number, output?: string): Promise<TfL['StopPoint']>;

@@ -48,3 +48,3 @@ "use strict";

StopPoint.prototype.getByIDs = function (ids, includeCrowdingData) {
return this.sendRequest("/StopPoint/" + tfl_1.default.arrayToCSV(ids), { includeCrowdingData: includeCrowdingData }, 'GET');
return this.sendRequest("/StopPoint/".concat(tfl_1.default.arrayToCSV(ids)), { includeCrowdingData: includeCrowdingData }, 'GET');
};

@@ -56,3 +56,3 @@ /**

StopPoint.prototype.getAllByStopType = function (types) {
return this.sendRequest("/StopPoint/Type/" + tfl_1.default.arrayToCSV(types), {}, 'GET');
return this.sendRequest("/StopPoint/Type/".concat(tfl_1.default.arrayToCSV(types)), {}, 'GET');
};

@@ -74,3 +74,3 @@ /**

StopPoint.prototype.search = function (name, modes) {
return this.sendRequest("/StopPoint/Search/" + name, { modes: modes }, 'GET');
return this.sendRequest("/StopPoint/Search/".concat(name), { modes: modes }, 'GET');
};

@@ -82,3 +82,3 @@ /**

StopPoint.prototype.getStationArrivals = function (id) {
return this.sendRequest("/StopPoint/" + id + "/Arrivals", {}, 'GET');
return this.sendRequest("/StopPoint/".concat(id, "/Arrivals"), {}, 'GET');
};

@@ -101,3 +101,3 @@ /**

StopPoint.prototype.getDisruptionsByID = function (ids, getFamily, includeRouteBlockedStops, flattenResponse) {
return this.sendRequest("/StopPoint/" + tfl_1.default.arrayToCSV(ids) + "/Disruption", {
return this.sendRequest("/StopPoint/".concat(tfl_1.default.arrayToCSV(ids), "/Disruption"), {
getFamily: getFamily,

@@ -114,3 +114,3 @@ includeRouteBlockedStops: includeRouteBlockedStops,

StopPoint.prototype.getDisruptionsByMode = function (modes, includeRouteBlockedStops) {
return this.sendRequest("/StopPoint/Mode/" + tfl_1.default.arrayToCSV(modes) + "/Disruption", { includeRouteBlockedStops: includeRouteBlockedStops }, 'GET');
return this.sendRequest("/StopPoint/Mode/".concat(tfl_1.default.arrayToCSV(modes), "/Disruption"), { includeRouteBlockedStops: includeRouteBlockedStops }, 'GET');
};

@@ -125,3 +125,3 @@ /**

if (serviceTypes === void 0) { serviceTypes = ['Regular']; }
return this.sendRequest("/StopPoint/" + id + "/CanReachOnLine/" + lineID, { serviceTypes: tfl_1.default.arrayToCSV(serviceTypes) }, 'GET');
return this.sendRequest("/StopPoint/".concat(id, "/CanReachOnLine/").concat(lineID), { serviceTypes: tfl_1.default.arrayToCSV(serviceTypes) }, 'GET');
};

@@ -135,3 +135,3 @@ /**

if (serviceTypes === void 0) { serviceTypes = ['Regular']; }
return this.sendRequest("/StopPoint/" + id + "/ ", { serviceTypes: tfl_1.default.arrayToCSV(serviceTypes) }, 'GET');
return this.sendRequest("/StopPoint/".concat(id, "/ "), { serviceTypes: tfl_1.default.arrayToCSV(serviceTypes) }, 'GET');
};

@@ -157,6 +157,5 @@ /**

* @param output If set to "web", a 302 redirect to relevant website bus stop page is returned. All other values are ignored.
* @returns ENGLISH > FRENCH
*/
StopPoint.prototype.getBySMSCode = function (smsID, output) {
return this.sendRequest("/StopPoint/Sms/" + smsID, { output: output }, 'GET');
return this.sendRequest("/StopPoint/Sms/".concat(smsID), { output: output }, 'GET');
};

@@ -168,3 +167,3 @@ /**

StopPoint.prototype.getTaxiRanksByID = function (id) {
return this.sendRequest("/StopPoint/" + id + "/TaxiRanks", {}, 'GET');
return this.sendRequest("/StopPoint/".concat(id, "/TaxiRanks"), {}, 'GET');
};

@@ -176,3 +175,3 @@ /**

StopPoint.prototype.getCarParksByID = function (id) {
return this.sendRequest("/StopPoint/" + id + "/CarParks", {}, 'GET');
return this.sendRequest("/StopPoint/".concat(id, "/CarParks"), {}, 'GET');
};

@@ -179,0 +178,0 @@ return StopPoint;

@@ -59,3 +59,3 @@ "use strict";

case 0:
FullURL = "https://" + this.host + ":" + this.port + uri + "?app_key=" + this.appKey;
FullURL = "https://".concat(this.host, ":").concat(this.port).concat(uri, "?app_key=").concat(this.appKey);
// Removed all undefined objects from params

@@ -65,3 +65,3 @@ Object.keys(params).forEach(function (key) { return (params[key] === undefined ? delete params[key] : {}); });

if (params)
FullURL = FullURL + "&" + qs.stringify(params);
FullURL = "".concat(FullURL, "&").concat(qs.stringify(params));
return [4 /*yield*/, axios_1.default.get(FullURL, { headers: { Accept: 'application/json', 'cache-control': 'no-cache' } })];

@@ -83,3 +83,3 @@ case 1:

switch (_a.label) {
case 0: return [4 /*yield*/, axios_1.default.get("http://cloud.tfl.gov.uk/TrackerNet" + uri, { headers: { Accept: 'application/xml', 'cache-control': 'no-cache' } })];
case 0: return [4 /*yield*/, axios_1.default.get("http://cloud.tfl.gov.uk/TrackerNet".concat(uri), { headers: { Accept: 'application/xml', 'cache-control': 'no-cache' } })];
case 1:

@@ -86,0 +86,0 @@ fetch = _a.sent();

@@ -70,3 +70,3 @@ "use strict";

switch (_a.label) {
case 0: return [4 /*yield*/, this.sendRequestTrackerNet("/PredictionSummary/" + line, 'GET', true)];
case 0: return [4 /*yield*/, this.sendRequestTrackerNet("/PredictionSummary/".concat(line), 'GET', true)];
case 1:

@@ -97,3 +97,3 @@ request = _a.sent();

console.error('You must enter a station code!');
return [4 /*yield*/, this.sendRequestTrackerNet("/PredictionDetailed/" + line + "/" + stationCode, 'GET', true)];
return [4 /*yield*/, this.sendRequestTrackerNet("/PredictionDetailed/".concat(line, "/").concat(stationCode), 'GET', true)];
case 1:

@@ -123,3 +123,3 @@ request = _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, this.sendRequestTrackerNet("/LineStatus" + TrackerNet.incidentsCheck(incidentsOnly), 'GET', false)];
case 0: return [4 /*yield*/, this.sendRequestTrackerNet("/LineStatus".concat(TrackerNet.incidentsCheck(incidentsOnly)), 'GET', false)];
case 1:

@@ -145,3 +145,3 @@ request = _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, this.sendRequestTrackerNet("/StationStatus" + TrackerNet.incidentsCheck(incidentsOnly), 'GET', false)];
case 0: return [4 /*yield*/, this.sendRequestTrackerNet("/StationStatus".concat(TrackerNet.incidentsCheck(incidentsOnly)), 'GET', false)];
case 1:

@@ -148,0 +148,0 @@ request = _a.sent();

@@ -79,3 +79,3 @@ "use strict";

return __generator(this, function (_a) {
return [2 /*return*/, this.sendRequest("/TravelTimes/overlay/" + z + "/mapcenter/" + mapCenterLat + "/" + mapCenterLon + "/pinLocation/" + pinLat + "/" + pinLon + "/dimensions/" + width + "/" + height, {}, 'GET')];
return [2 /*return*/, this.sendRequest("/TravelTimes/overlay/".concat(z, "/mapcenter/").concat(mapCenterLat, "/").concat(mapCenterLon, "/pinLocation/").concat(pinLat, "/").concat(pinLon, "/dimensions/").concat(width, "/").concat(height), {}, 'GET')];
});

@@ -82,0 +82,0 @@ });

{
"name": "tfl-api-wrapper",
"version": "1.6.0",
"version": "1.6.1",
"description": "A Node JS wrapper for the Transport for London API",

@@ -13,3 +13,3 @@ "main": "dist/index.js",

"build": "tsc",
"build-docs": "typedoc",
"build-docs": "typedoc --plugin ./typedoc/returnType.js",
"watch": "tsc-watch --onSuccess \"node dist/index.js\"",

@@ -38,6 +38,5 @@ "prettier": "prettier --write ./**/*.ts"

"tsc-watch": "^4.2.9",
"typedoc": "^0.22.10",
"typedoc-default-themes-dark": "^0.12.10",
"typedoc-theme-dark": "^0.0.5",
"typescript": "^4.4.2"
"typedoc": "^0.22.11",
"typedoc-theme-dark": "0.0.5",
"typescript": "^4.5.4"
},

@@ -44,0 +43,0 @@ "directories": {

@@ -31,13 +31,15 @@

### Line
### Async... await
```js
import { Line } from 'tfl-api-wrapper';
import { StopPoint } from 'tfl-api-wrapper';
const config = {
app_key: 'API KEY HERE',
};
const line = new Line(config)
const app_key = 'API KEY HERE'; // Use an environment file
const stopPoint = new StopPoint(app_key)
const arrivals = await stopPoint.getStationArrivals('940GZZLUKSX');
console.log(arrivals);
```
### StopPoint
### Callback

@@ -47,6 +49,8 @@ ```js

const config = {
app_key: 'API KEY HERE',
};
const stopPoint = new StopPoint(config)
const app_key = 'API KEY HERE'; // Use an environment file
const stopPoint = new StopPoint(app_key)
stopPoint.getStationArrivals('940GZZLUKSX').then((arrivals) => {
console.log(arrivals)
});
```

@@ -53,0 +57,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc