Skip to content

bttmly/bart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bart

A small JavaScript wrapper around the BART XML API. Works in web browsers and Node.js.

Installation & Usage

The name bart was taken, so...

npm install --save bay-area-rapid-transit

Basic usage

const Bart = require("bay-area-rapid-transit")
const client = new Bart("MY_API_KEY")

Configuring fetch

When using this module in Node.js, you must either provide a global fetch that is compatible with the Fetch API, or pass a fetch function to the client at initialization time.

const { fetch } = require("fetch-ponyfill")() // https://github.com/qubyte/fetch-ponyfill
const Bart = require("bay-area-rapid-transit")
const client = new Bart({ key: "MY_API_KEY", fetch })

Alternately, you can call methods directly on the Bart object if you provide the API key as key in params. Each method takes an object of params as the first argument and an optional callback as the second. If no callback is provided, a promise is returned.

Supports the following methods, which map directly to the BART API endpoints:

  • advisories
  • trainCount
  • elevatorInformation
  • realTimeEstimates
  • routes
  • routesInformation
  • quickPlannerArrive
  • quickPlannerDepart
  • fare
  • holidays
  • loadFactor
  • routeSchedule
  • availableSchedules
  • specialSchedules
  • stationSchedule
  • stationList
  • stationInformation
  • stationAccessInformation

test/index.js has integration tests for each method and schemas against which the responses are validated. More documentation may eventually be added to this readme but the test file should suffice for most uses.

About

An ergonomic JavaScript client for the BART XML API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors