JSPM

wmata-api-node

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q25202F
  • License MIT

Washington Metropolitan Area Transit Authority Node API Wrapper

Package Exports

  • wmata-api-node

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wmata-api-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Washington Metropolitan Area Transit Authority API Node.JS Wrapper

Tests Coverage Status

This is a wrapper for the WMATA Web API that runs on Node.JS.

It includes helper functions to do the following:

Bus Information

  • Bus positions
  • Bus arrival time predictions

Train Information

  • Train positions
  • Train arrival time predictions
Dependencies

This project deponds on request to make HTTP requests.

Installation

$ npm install wmata-api-node --save

Usage

First, instantiate the wrapper.

var WmataApi = require('wmata-api-node');

// Instantiate the api with your api key
var wmataApi = new WmataApi('mysupersecretkey123');

Use the wrapper's methods to make requests to WMATA's web API. Methods use promises, so be sure to provide success and error handlers.

// Get bus positions for the D2 line 
wmataApi.getBusPositions('D2')
    .then(data => {
        console.log('Bus positions', data.BusPositions);
    })
    .catch(err => {
        console.error(err);
    });

Authorization

You must provide an API key to the wrapper at instantiation. See WMATA's API documentation for steps on obtaining your free API key.

Development

Discover a bug, or have improvements? Open an issue or clone the project and send a pull request with your changes!

Running tests

You can run unit tests by executing mocha.