Skip to content

๐ŸšŒ Node.js wrapper for MTA-BusTime REST API

Notifications You must be signed in to change notification settings

json2d/mta-bustime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

mta-bustime

๐ŸšŒ Node.js wrapper for MTA-BusTime REST API

Installation

npm install mta-bustime --save

Usage

First, create a BusTime object with your API key.

const BusTime = require('mta-bustime')

var bustime = new BusTime(API_KEY)

Then, use the wrapper functions to make requests to the API endpoints and retrieve the responses

// OneBusAway API
bustime.agenciesWithCoverage({/* options */},function(err,res,body) { /* do something with response */ })
bustime.routesForAgency('MTA NYCT',{/* options */},function(err,res,body) { /* do something with response */ })
bustime.stopsForRoute('MTA NYCT_B70',{includePolylines:false /* , more options */ },function(err,res,body) { /* do something with response */ })


var LineRef ='B70',
  DirectionRef = 0,
  MonitoringRef = 308194

// SIRI API
bustime.stopMonitoring({LineRef,DirectionRef,MonitoringRef},function(err,res,body) { /* do something with response */ })

For more information on the API endpoints and available query options for each, see the references below: http://bustime.mta.info/wiki/Developers/OneBusAwayRESTfulAPI http://bustime.mta.info/wiki/Developers/SIRIStopMonitoring

Tests

To run tests on the wrapper functions, first you'll need to create the file /test/config/.env with your API key like this:

KEY=<your-API-key>

Then run the script:

npm test

Responses for test API requests are saved to test/cache for further inspection.

Dependencies

  • request: Simplified HTTP request client.

Dev Dependencies

  • tap: A Test-Anything-Protocol library
  • dotenv: Loads environment variables from .env file

License

MIT

About

๐ŸšŒ Node.js wrapper for MTA-BusTime REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published