New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1.3 to 1.2.0

17

dist/lib/line.d.ts

@@ -6,13 +6,20 @@ import TfLAPI from './tfl';

/** Get all valid modes */
listValidModes(): Promise<any>;
getValidModes(): Promise<any>;
/** Gets a list of all severity codes */
listSeverityCodes(): Promise<any>;
getSeverityCodes(): Promise<any>;
/** Gets a list of all disruption types */
listDisruptionCategories(): Promise<any>;
getDisruptionCategories(): Promise<any>;
/** Gets a list of all service types */
listServiceTypes(): Promise<any>;
getServiceTypes(): Promise<any>;
/** Gets a list of the stations that serve the given line id */
listAllStopPoints(line: string): Promise<any>;
getAllStopPoints(line: string): Promise<any>;
/** Gets all lines that serve the given modes. */
getAllLinesFromMode(modes: Array<string | number>): Promise<any>;
/** Get the list of arrival predictions for given line ids based at the given stop
* @param ids list of line ids e.g. ['victoria','circle','N133']
* @param NaptanID Id of stop to get arrival predictions for (station naptan code e.g. 940GZZLUASL)
* @param direction Optional. The direction of travel. Can be inbound or outbound or all. Default: all
* @param destinationStationId Optional. Id of destination stop
*/
getArrivalsByNaptan(ids: Array<string>, NaptanID: string, direction?: string, destinationStationId?: string): Promise<any>;
/** Gets the timetable for a specified station on the give line with specified destination */

@@ -19,0 +26,0 @@ getTimetableFromTo(line: string, from: string, to: string): Promise<any>;

@@ -33,19 +33,19 @@ 'use strict';

/** Get all valid modes */
Line.prototype.listValidModes = function () {
Line.prototype.getValidModes = function () {
return this.sendRequest('/Line/Meta/Modes', {}, 'GET');
};
/** Gets a list of all severity codes */
Line.prototype.listSeverityCodes = function () {
Line.prototype.getSeverityCodes = function () {
return this.sendRequest('/Line/Meta/Severity', {}, 'GET');
};
/** Gets a list of all disruption types */
Line.prototype.listDisruptionCategories = function () {
Line.prototype.getDisruptionCategories = function () {
return this.sendRequest('/Line/Meta/DisruptionCategories', {}, 'GET');
};
/** Gets a list of all service types */
Line.prototype.listServiceTypes = function () {
Line.prototype.getServiceTypes = function () {
return this.sendRequest('/Line/Meta/ServiceTypes', {}, 'GET');
};
/** Gets a list of the stations that serve the given line id */
Line.prototype.listAllStopPoints = function (line) {
Line.prototype.getAllStopPoints = function (line) {
return this.sendRequest('/Line/' + line + '/StopPoints', {}, 'GET');

@@ -57,2 +57,14 @@ };

};
/** Get the list of arrival predictions for given line ids based at the given stop
* @param ids list of line ids e.g. ['victoria','circle','N133']
* @param NaptanID Id of stop to get arrival predictions for (station naptan code e.g. 940GZZLUASL)
* @param direction Optional. The direction of travel. Can be inbound or outbound or all. Default: all
* @param destinationStationId Optional. Id of destination stop
*/
Line.prototype.getArrivalsByNaptan = function (ids, NaptanID, direction, destinationStationId) {
if (direction === void 0) {
direction = 'all';
}
return this.sendRequest('/Line/' + this.arrayToCSV(ids) + '/Arrivals/' + NaptanID, { direction: direction, destinationStationId: destinationStationId }, 'GET');
};
/** Gets the timetable for a specified station on the give line with specified destination */

@@ -59,0 +71,0 @@ Line.prototype.getTimetableFromTo = function (line, from, to) {

@@ -11,17 +11,27 @@ import tflAPI from './tfl';

* Get the road with the specified ID (Eg. A1)
* @param id ID(s) of the road(s)
* @param ids ID(s) of the road(s)
*/
getByID(...id: Array<string>): Promise<any>;
getByID(ids: Array<string>): Promise<any>;
/**
* Gets the specified roads with the status aggregated over the date range specified, or now until the end of today if no dates are passed.
* Gets the specified roads with the status aggregated over the date range specified, or now until the end of today if no dates are passed
* @param ids
* @param startDate
* @param endDate
* @param id
*/
getStatusByID(startDate: any, endDate: any, ...id: Array<string>): Promise<any>;
getStatusByID(ids: Array<string>, startDate?: Date, endDate?: Date): Promise<any>;
/**
* Gets a list of disrupted streets
* @param startDate
* @param endDate
*/
getAllStreetDisruption(): Promise<any>;
getAllStreetDisruption(startDate: Date, endDate: Date): Promise<any>;
/**
* Gets a list of active disruptions filtered by disruption Ids.
* @param ids
* @param stripContent When true, removes every property/node
* except for id, point, severity, severityDescription,
* startDate, endDate, corridor details, location and comments.
*/
getAllDisruptionsByID(ids: Array<string>, stripContent?: boolean): Promise<any>;
/**
* Gets a list of valid RoadDisruption categories

@@ -28,0 +38,0 @@ */

@@ -40,34 +40,20 @@ 'use strict';

* Get the road with the specified ID (Eg. A1)
* @param id ID(s) of the road(s)
* @param ids ID(s) of the road(s)
*/
Road.prototype.getByID = function () {
var id = [];
for (var _i = 0; _i < arguments.length; _i++) {
id[_i] = arguments[_i];
}
return this.sendRequest('/Road/' + this.arrayToCSV(id), {}, 'GET');
Road.prototype.getByID = function (ids) {
return this.sendRequest('/Road/' + this.arrayToCSV(ids), {}, 'GET');
};
/**
* Gets the specified roads with the status aggregated over the date range specified, or now until the end of today if no dates are passed.
* Gets the specified roads with the status aggregated over the date range specified, or now until the end of today if no dates are passed
* @param ids
* @param startDate
* @param endDate
* @param id
*/
Road.prototype.getStatusByID = function (startDate, endDate) {
var _a;
var id = [];
for (var _i = 2; _i < arguments.length; _i++) {
id[_i - 2] = arguments[_i];
}
if (startDate && endDate) {
startDate = startDate.toISOString().split('.')[0] + 'Z';
endDate = ((_a = endDate.toISOString()) === null || _a === void 0 ? void 0 : _a.split('.')[0]) + 'Z';
} else {
startDate = '';
endDate = '';
}
console.log(startDate);
Road.prototype.getStatusByID = function (ids, startDate, endDate) {
return this.sendRequest(
'/Road/' + this.arrayToCSV(id) + '/Status',
{ startDate: startDate === null || startDate === void 0 ? void 0 : startDate.toString(), endDate: endDate === null || endDate === void 0 ? void 0 : endDate.toString() },
'/Road/' + this.arrayToCSV(ids) + '/Status',
{
startDate: this.convertDate(startDate),
endDate: this.convertDate(endDate),
},
'GET'

@@ -78,7 +64,32 @@ );

* Gets a list of disrupted streets
* @param startDate
* @param endDate
*/
Road.prototype.getAllStreetDisruption = function () {
return this.sendRequest('/Road/all/Street/Disruption', {}, 'GET');
Road.prototype.getAllStreetDisruption = function (startDate, endDate) {
return this.sendRequest(
'/Road/all/Street/Disruption',
{
startDate: this.convertDate(startDate),
endDate: this.convertDate(endDate),
},
'GET'
);
};
/**
* Gets a list of active disruptions filtered by disruption Ids.
* @param ids
* @param stripContent When true, removes every property/node
* except for id, point, severity, severityDescription,
* startDate, endDate, corridor details, location and comments.
*/
Road.prototype.getAllDisruptionsByID = function (ids, stripContent) {
return this.sendRequest(
'/Road/all/Disruption/' + this.arrayToCSV(ids),
{
stripContent: stripContent,
},
'GET'
);
};
/**
* Gets a list of valid RoadDisruption categories

@@ -85,0 +96,0 @@ */

@@ -6,2 +6,32 @@ import TfLAPI from './tfl';

/**
* Gets the list of available StopPoint additional information categories
*/
getCategories(): Promise<any>;
/**
* Gets the list of available StopPoint types
*/
getTypes(): Promise<any>;
/**
* Gets the list of available StopPoint modes
*/
getModes(): Promise<any>;
/**
* Gets a list of StopPoints corresponding to the given list of stop ids
* @param ids A list of stop point ids (station naptan code e.g. 940GZZLUASL).
* @param includeCrowding Include the crowding data (static). To Filter further use: /StopPoint/{ids}/Crowding/{line}
*/
getByIDs(ids: Array<string>, includeCrowding: boolean): Promise<any>;
/**
* Gets all stop points of a given type
* @param types A list of valid stop types can be obtained from the StopPoint/meta/stoptypes endpoint
*/
getAllByStopType(types: Array<string>): Promise<any>;
/**
* Gets the service types for a given Stop Point
* @param id
* @param lineIds
* @param modes
*/
getServiceTypesByID(id: string, lineIds?: Array<string>, modes?: Array<string>): Promise<any>;
/**
* Search StopPoints by their common name. Will not return a valid NaPTAN for HUB

@@ -13,13 +43,19 @@ * @param name Name of station

/**
* Get all service arrivals and departures
* @param id
* Get all service arrivals
* @param id A StopPoint id (station naptan code e.g. 940GZZLUAS)
*/
listStationArrivals(id: string): Promise<any>;
getStationArrivals(id: string): Promise<any>;
/**
* Gets all disruptions for the specified StopPointId, plus disruptions for any child Naptan records it may have.
* @param NaPTAN
*
* @param id A StopPoint id (station naptan code e.g. 940GZZLUAS)
* @param lineIds List of line ids e.g. tfl-rail, london-overground, thameslink
*/
getArrivalDepartures(id: string, lineIds: Array<string>): Promise<any>;
/**
* Gets all disruptions for the specified StopPointId, plus disruptions for any child Naptan records it may have
* @param id
* @param getFamily Specify true to return disruptions for entire family, or false to return disruptions for just this stop point. Defaults to false.
* @param flattenResponse Specify true to associate all disruptions with parent stop point. (Only applicable when getFamily is true).
* @param flattenResponse Specify true to associate all disruptions with parent stop point. (Only applicable when getFamily is true)
*/
getDisruptionsByNaPTAN(NaPTAN: string, getFamily: boolean, flattenResponse: boolean): Promise<any>;
getDisruptionsByID(id: string, getFamily: boolean, flattenResponse: boolean): Promise<any>;
/**

@@ -32,7 +68,25 @@ * Gets a distinct list of disrupted stop points for the given modes

* Gets Stop points that are reachable from a station/line combination
* @param NaPTAN
* @param id The id (station naptan code e.g. 940GZZLUASL)
* @param lineID Line id of the line to filter by (e.g. victoria)
* @param serviceType Supported values: Regular, Night. Defaulted to 'Regular' if not specified
* @param serviceTypes List of service types to filter on. Supported values: Regular, Night. Defaulted to 'Regular'.
*/
getReachableStationsByNaPTAN(NaPTAN: string, lineID: string, serviceType?: Array<string>): Promise<any>;
getReachableStationsByID(id: string, lineID: string, serviceTypes?: Array<string>): Promise<any>;
/**
* Get the route sections for all the lines that service the given stop point id
* @param id
* @param serviceTypes List of service types to filter on. Supported values: Regular, Night. Defaulted to 'Regular'.
*/
getRouteSectionByID(id: string, serviceTypes?: Array<string>): Promise<any>;
/**
* Gets a list of StopPoints within {radius} by the specified criteria
* @param stopTypes a list of stopTypes that should be returned.
* @param radius The radius of the bounding circle in metres (default : 200)
* @param useStopPointHierarchy Re-arrange the output into a parent/child hierarchy.
* @param modes The list of modes to search (e.g. tube, dlr)
* @param categories an optional list of comma separated property categories to return in the StopPoint's property bag. If null or empty, all categories of property are returned. Pass the keyword "none" to return no properties.
* @param returnLines True to return the lines that each stop point serves as a nested resource.
* @param latitude
* @param longitude
*/
getInRadius(stopTypes: Array<string>, radius: number | undefined, useStopPointHierarchy: boolean, modes: Array<string>, categories: Array<string>, returnLines: boolean, latitude: number, longitude: number): Promise<any>;
}

@@ -33,2 +33,44 @@ 'use strict';

/**
* Gets the list of available StopPoint additional information categories
*/
StopPoint.prototype.getCategories = function () {
return this.sendRequest('/StopPoint/Meta/Categories', {}, 'GET');
};
/**
* Gets the list of available StopPoint types
*/
StopPoint.prototype.getTypes = function () {
return this.sendRequest('/StopPoint/Meta/StopTypes', {}, 'GET');
};
/**
* Gets the list of available StopPoint modes
*/
StopPoint.prototype.getModes = function () {
return this.sendRequest('/StopPoint/Meta/Modes', {}, 'GET');
};
/**
* Gets a list of StopPoints corresponding to the given list of stop ids
* @param ids A list of stop point ids (station naptan code e.g. 940GZZLUASL).
* @param includeCrowding Include the crowding data (static). To Filter further use: /StopPoint/{ids}/Crowding/{line}
*/
StopPoint.prototype.getByIDs = function (ids, includeCrowding) {
return this.sendRequest('/StopPoint/' + this.arrayToCSV(ids), { includeCrowding: includeCrowding }, 'GET');
};
/**
* Gets all stop points of a given type
* @param types A list of valid stop types can be obtained from the StopPoint/meta/stoptypes endpoint
*/
StopPoint.prototype.getAllByStopType = function (types) {
return this.sendRequest('/StopPoint/' + this.arrayToCSV(types), {}, 'GET');
};
/**
* Gets the service types for a given Stop Point
* @param id
* @param lineIds
* @param modes
*/
StopPoint.prototype.getServiceTypesByID = function (id, lineIds, modes) {
return this.sendRequest('/StopPoint/ServiceTypes', { id: id, lineIds: lineIds, modes: modes }, 'GET');
};
/**
* Search StopPoints by their common name. Will not return a valid NaPTAN for HUB

@@ -42,17 +84,25 @@ * @param name Name of station

/**
* Get all service arrivals and departures
* @param id
* Get all service arrivals
* @param id A StopPoint id (station naptan code e.g. 940GZZLUAS)
*/
StopPoint.prototype.listStationArrivals = function (id) {
StopPoint.prototype.getStationArrivals = function (id) {
return this.sendRequest('/StopPoint/' + id + '/Arrivals', {}, 'GET');
};
/**
* Gets all disruptions for the specified StopPointId, plus disruptions for any child Naptan records it may have.
* @param NaPTAN
*
* @param id A StopPoint id (station naptan code e.g. 940GZZLUAS)
* @param lineIds List of line ids e.g. tfl-rail, london-overground, thameslink
*/
StopPoint.prototype.getArrivalDepartures = function (id, lineIds) {
return this.sendRequest('/StopPoint/' + id + '/ArrivalsDepartures', {}, 'GET');
};
/**
* Gets all disruptions for the specified StopPointId, plus disruptions for any child Naptan records it may have
* @param id
* @param getFamily Specify true to return disruptions for entire family, or false to return disruptions for just this stop point. Defaults to false.
* @param flattenResponse Specify true to associate all disruptions with parent stop point. (Only applicable when getFamily is true).
* @param flattenResponse Specify true to associate all disruptions with parent stop point. (Only applicable when getFamily is true)
*/
StopPoint.prototype.getDisruptionsByNaPTAN = function (NaPTAN, getFamily, flattenResponse) {
StopPoint.prototype.getDisruptionsByID = function (id, getFamily, flattenResponse) {
return this.sendRequest(
'/StopPoint/' + NaPTAN + '/Disruption',
'/StopPoint/' + id + '/Disruption',
{

@@ -74,14 +124,55 @@ getFamily: getFamily,

* Gets Stop points that are reachable from a station/line combination
* @param NaPTAN
* @param id The id (station naptan code e.g. 940GZZLUASL)
* @param lineID Line id of the line to filter by (e.g. victoria)
* @param serviceType Supported values: Regular, Night. Defaulted to 'Regular' if not specified
* @param serviceTypes List of service types to filter on. Supported values: Regular, Night. Defaulted to 'Regular'.
*/
StopPoint.prototype.getReachableStationsByNaPTAN = function (NaPTAN, lineID, serviceType) {
if (serviceType === void 0) {
serviceType = ['Regular'];
StopPoint.prototype.getReachableStationsByID = function (id, lineID, serviceTypes) {
if (serviceTypes === void 0) {
serviceTypes = ['Regular'];
}
return this.sendRequest('/StopPoint/' + NaPTAN + '/CanReachOnLine/' + lineID, { serviceTypes: serviceType }, 'GET');
return this.sendRequest('/StopPoint/' + id + '/CanReachOnLine/' + lineID, { serviceTypes: this.arrayToCSV(serviceTypes) }, 'GET');
};
/**
* Get the route sections for all the lines that service the given stop point id
* @param id
* @param serviceTypes List of service types to filter on. Supported values: Regular, Night. Defaulted to 'Regular'.
*/
StopPoint.prototype.getRouteSectionByID = function (id, serviceTypes) {
if (serviceTypes === void 0) {
serviceTypes = ['Regular'];
}
return this.sendRequest('/StopPoint/' + id + '/Route', { serviceTypes: this.arrayToCSV(serviceTypes) }, 'GET');
};
/**
* Gets a list of StopPoints within {radius} by the specified criteria
* @param stopTypes a list of stopTypes that should be returned.
* @param radius The radius of the bounding circle in metres (default : 200)
* @param useStopPointHierarchy Re-arrange the output into a parent/child hierarchy.
* @param modes The list of modes to search (e.g. tube, dlr)
* @param categories an optional list of comma separated property categories to return in the StopPoint's property bag. If null or empty, all categories of property are returned. Pass the keyword "none" to return no properties.
* @param returnLines True to return the lines that each stop point serves as a nested resource.
* @param latitude
* @param longitude
*/
StopPoint.prototype.getInRadius = function (stopTypes, radius, useStopPointHierarchy, modes, categories, returnLines, latitude, longitude) {
if (radius === void 0) {
radius = 200;
}
return this.sendRequest(
'/StopPoint',
{
stopTypes: this.arrayToCSV(stopTypes),
radius: radius,
useStopPointHierarchy: useStopPointHierarchy,
modes: this.arrayToCSV(modes),
categories: this.arrayToCSV(categories),
returnLines: returnLines,
latitude: latitude,
longitude: longitude,
},
'GET'
);
};
return StopPoint;
})(tfl_1.default);
exports.default = StopPoint;

@@ -19,2 +19,6 @@ import * as interfaces from './interfaces';

arrayToCSV(arr: Array<string | number>): string;
/**
* @ignore
*/
convertDate(oldDate: Date | undefined): string;
}

@@ -176,4 +176,10 @@ 'use strict';

};
/**
* @ignore
*/
TfLAPI.prototype.convertDate = function (oldDate) {
return (oldDate === null || oldDate === void 0 ? void 0 : oldDate.toISOString().split('.')[0]) + 'Z';
};
return TfLAPI;
})();
exports.default = TfLAPI;
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var line_1 = require('../lib/line');
var stopPoint_1 = require('../lib/stopPoint');
var line = new line_1.default({
app_key: '',
});
var stopPoint = new stopPoint_1.default({
app_key: '',
});
stopPoint.listStationArrivals('940GZZLUHSC').then(function (res) {
console.log(res);
});
// stopPoint.searchStopPoint('kings cross', 'tube').then((r) => {
// console.log(r.matches[0].id);
// });
// client.sendRequest('StopPoint/Search/farringdon', {}, 'GET')
{
"name": "tfl-api-wrapper",
"version": "1.1.3",
"version": "1.2.0",
"description": "A Node JS wrapper for the Transport for London API",

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

"keywords": [
"tfl, api, wrapper, typescript"
"tfl",
"api",
"wrapper",
"typescript"
],

@@ -20,0 +23,0 @@ "author": "zackaryh8",

@@ -8,3 +8,4 @@ <p align="center">

[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/ZackaryH8/tfl-api-wrapper.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ZackaryH8/tfl-api-wrapper/context:javascript)
![Issues](https://img.shields.io/github/issues/ZackaryH8/tfl-api-wrapper)
## Installation

@@ -11,0 +12,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