Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/json2d/mta-bustime
🚌 Node.js wrapper for MTA-BusTime REST API
https://github.com/json2d/mta-bustime
Last synced: 27 days ago
JSON representation
🚌 Node.js wrapper for MTA-BusTime REST API
- Host: GitHub
- URL: https://github.com/json2d/mta-bustime
- Owner: json2d
- Created: 2017-06-19T00:29:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-22T02:55:37.000Z (over 7 years ago)
- Last Synced: 2024-12-01T09:36:02.703Z (about 1 month ago)
- Language: JavaScript
- Size: 259 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mta-bustime
🚌 Node.js wrapper for MTA-BusTime REST API
## Installation
```sh
npm install mta-bustime --save
```## Usage
First, create a `BusTime` object with your API key.
```javascript
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
```javascript
// 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=
```Then run the script:
```sh
npm test
```Responses for test API requests are saved to `test/cache` for further inspection.
## Dependencies
- [request](https://github.com/request/request): Simplified HTTP request client.
## Dev Dependencies
- [tap](https://github.com/tapjs/node-tap): A Test-Anything-Protocol library
- [dotenv](https://github.com/motdotla/dotenv): Loads environment variables from .env file## License
MIT