npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-wmata-bus

v1.4.2

Published

[![BuildStatus](https://travis-ci.org/jacksongeller/node-wmata-bus.svg?branch=master)](https://travis-ci.org/jacksongeller/node-wmata-bus)

Downloads

4

Readme

wmata-bus-js

BuildStatus

Looking for metro trains?

Check out this

Install

$ npm install node-wmata-bus --save

Use

  1. Get API key
  2. Init client
var Bus = require('node-wmata-bus');
var client = new Bus('api key here');

API

getBusRoutes(done)

Get all bus routes

Parameters

done: function, callback(err, response)

Returns: Array, - returns list of bus routes

getBusStops(loc, radius, done)

Get all bus stops

Parameters

loc: Object, coordinates in object format loc.lat, loc.lon

radius: number, the radius in meters

done: function, callback(err, response)

Returns: Array, - returns list of bus stops

getBusScheduleByRoute(id, date, variation, done)

Get bus schedules by route

Parameters

id: String, Bust Route ID

date: String, date in year-month-day format

variation: String, variation true or false, in string format

done: function, callback(err, response)

Returns: Array, - returns list schedule by routes

getBusRouteDetails(id, date, done)

Get bus route details

Parameters

id: String, bus route ID

date: String, date in year-month-day format

done: function, callback(err, response)

Returns: Array, - returns list of bus route details

getBusPositions(id, variation, loc, radius, done)

[getBusPositions description]

Parameters

id: String, Route ID

variation: String, bool in string format

loc: Object, coordinates in object format loc.lat, loc.lon

radius: Number, radius in meters of bus positions

done: function, callback(err, response)

Returns: Array, - returns list of bus positions

getBusScheduleByStop(id, date, done)

Get bus schedules by stops

Parameters

id: String, bus stopID

date: String, data in year-month-day format

done: function, callback(err, response)

Returns: Array, - returns list of schedules by stop

getBusPrediction(id, done)

Get bus predictions

Parameters

id: String, bus stopID

done: function, callback(err, response)

Returns: Array, - returns list of predictions

getClosestStationsPrediction(loc, radius, limit, done)

Get station predictions based on the closest stations given a location. Great for getting predictions, without nowing the stations within a location.

Parameters

loc: Object, coordinates in object format loc.lat, loc.lon

radius: Number, radius in meters

limit: Number, max amount of stations to include

done: function, callback(err, response)

Returns: Array, - returns list of bus station predictions, sorted by closest to location provided

getBusPredictionSeries(arr, done)

Get bus predictions, in a series. Great if you have a list of stations, and need to get predictions for all of them.

Parameters

arr: Array, list of station ids

done: function, callback(err, response)

Returns: Array, - returns list of corresponding predictions


Examples

var Bus = require('wmata-bus-js');
var client = new Bus('api key here');
var location = {
  lat: 41,
  lon: 39
}

client.getBusRoutes(function(err, data) {
  // do something with data
});

client.getBusStops(location, '500', function(err, data) {
  // do something with data
});

client.getBusScheduleByRoute('16L', '2014-09-19', 'false', function(err, data) {
  // do something with data
});

client.getBusRouteDetails('16L', '2014-09-19', function(err, data) {
  // do something with data
});

client.getBusPositions('10A', 'true', location, 500, function(err, data) {
  // do something with data
});

client.getBusScheduleByStop('2000019', '2014-09-19', function(err, data) {
  // do something with data
});

client.getBusPrediction('1001343', function(err, data) {
  // do something with data
});

client.getClosestPrediction(location, 500, 3, function(err, data) {
  // do something with data
});