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.
nxtbus
Advanced tools
Readme
TypeScript wrapper for Transport Canberra's NXTBUS API.
This package allows translation to a more modern JSON format compared to the XML garbage which NXTBUS spits out.
Register for an API key here
Install with npm
:
npm i nxtbus
Use in a Node JS/TS project:
import { NxtbusAPI } from 'nxtbus';
const nxtbus = new NxtbusAPI(process.env.NXTBUS_API_KEY)
const route45BusLocations = await nxtbus.getBusLocations(45)
const locationJson = await route45BusLocations.json()
console.log(JSON.stringify(locationJson, null, 2))
Produces:
{
"timestamp": "2023-01-03T16:19:03+11:00",
"status": true,
"vehicles": [
{
"recordedAt": "2023-01-03T16:18:51.549+11:00",
"validUntil": "2023-01-03T16:29:03+11:00",
"route": "VM_ACT_0045",
"progress": {
"distance": 294,
"percentage": 54
},
"bus": {
"direction": "B",
"datedVehicleJourney": "3043-00004-1",
"pattern": "115",
...
Our nxtbus
module provides integration with ACT Government's bus stop and vehicle monitoring API.
Each API function returns a form of ServiceResponse
, which can display both XML and JSON outputs, as well as an interactive cheerio
interface within Node.
Note: see the official API reference PDF linked above for information on specific fields.
Once you have an API key, you can create an instance of nxtbus
like so:
NxtbusAPI
class:
import { NxtbusAPI } from 'nxtbus'
const nxtbus = new NxtbusAPI(process.env.NXTBUS_API_KEY)
Now you can pull data from the API.
To track all buses on a specific route, use nxtbus.getBusLocations
.
Let's get the bus locations on route 45, and return it in both XML and JSON formats.
await
the getBusLocations
function:
const locations = await nxtbus.getBusLocations(45)
console.log(locations.xml)
nxtbus
package does some work in the background to add the locations of bus stops.
const locationsJson = await locations.json()
console.log(JSON.stringify(locationsJson, null, 2))
To track incoming buses for a specific stop, first you need the bus stop's ID. That can be obtained from the CSV located here (The nxtbus
package pulls this file in the background for up-to-date bus stop information).
The same XML/JSON rules apply here. XML will be skipped; we'll just print the JSON output.
This will uses the bus stop 4455 - Erldunda Cct opp Hawker PS
await
the getIncomingBuses
function:
const busesToStop = await nxtbus.getIncomingBuses(4455)
await
the JSON return:
const stopJson = await busesToStop.json()
console.log(JSON.stringify(stopJson, null, 2))
Add productionTimetable
and estimatedTimetable
endpoints.
FAQs
JavaScript module for Transport Canberra's NXTBUS API
The npm package nxtbus receives a total of 3 weekly downloads. As such, nxtbus popularity was classified as not popular.
We found that nxtbus 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.