Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
node-emtmad-bus-promise
Advanced tools
Readme
Node.js module to access services from the public API of the Public Transport Authority of Madrid, Spain (EMT).
This module is a fork of https://github.com/alvaroreig/emtmad-bus-times-node that returns Promise objects instead of doing sync calls to the EMT API.
Request access to the API at http://opendata.emtmadrid.es/Formulario. You will be given a Client ID and a Passkey.
node-emtmad-bus-promise is packaged using NPM. Just require the package inside your code:
var EMTAPI = require('node-emtmad-bus-promise');
In order to use this API you need to set two environment variables with your Client ID and Passkey. These variables need to be set before using require on the module.
EMT_APP_ID = <your client id>
EMT_PASSKEY = <your passkey>
Call the function getIncomingBusesToStop(busStopNumber) and a Promise will be returned that fulfills to an array of estimations:
let stop = {
Id: 3041
}
EMTAPI.getIncomingBusesToStop(stop.Id)
.then(function (arriving) {
stop.arriving = arriving;
resolve(stop);
})
.catch(function (error) {
resolve(`Error: ${error}`);
});
The array of estimations is built with Bus objects that represent an incoming bus to the specified bus stop. The most relevant attributes for each bus are:
{
"lineId": "32", // The line of the bus
"busDistance": 9, // In meters
"busTimeLeft": 0 // In seconds
}
Call the function getStopsFromLocation(location, radius) and a Promise will be returned that fulfills to an array of stops:
let location = {
latitude: -3.7324823992585,
longitude: 40.377653538528
}
let searchRadius = 250;
EMTAPI.getStopsFromLocation(location, searchRadius)
.then(function (stops) {
// do something
})
.catch(function (error) {
resolve(`Error: ${error}`);
});
The array of stops is built with Stop objects that look like this:
{
stopId: '2443',
name: 'AV.ABRANTES-PZA.LASMENINAS',
postalAddress: 'Av.deAbrantes, 106',
longitude: -3.7324823992585,
latitude: 40.377653538528,
line: [Line Object]
}
Call the function getStopsLine(line, direction) and a Promise will be returned that fulfills to the whole of object returned by the EMT API. Since this query is pretty time consuming, the results are cached per line/direction combination to speed up things.
let line = "118"; // line should be the lineId and not the label of the line
let direction = 1; // lines have two directions represented either by: 1 or 2
EMTAPI.getStopsLine(line, direction)
.then(function (results) {
// do something
})
.catch(function (error) {
resolve(`Error: ${error}`);
});
The object is described in the EMT API and looks like this:
{
lineId: 516, // Line Id
label: 'N16', // Label for this line
destination: 'TEXT', // Destination of line
incidents: 0 // 0: No incidents, 1: Incidents
stop: [] // List of Stop
line: [] // List of Line
}
The objects returned in this API are exactly the same as the EMT API. A comprehensive documentation of the objects returned by the EMT API can be downloaded in the following link: http://opendata.emtmadrid.es/Documentos/Opendata-v-1-12.aspx
Do you want to contribute? Great! Pull requests are more than welcome.
FAQs
Nodejs library to access services from the public API of the Public Transport Authority of Madrid, Spain (EMT) with a Promises twist
The npm package node-emtmad-bus-promise receives a total of 0 weekly downloads. As such, node-emtmad-bus-promise popularity was classified as not popular.
We found that node-emtmad-bus-promise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.