OneBusAway RESTful API

Version 1.1 by admin admin on 2024/07/23 03:11

== MTA Bus Time and the OneBusAway API ==

MTA Bus Time is powered (in part) by the open source {{html}}<a href="https://github.com/OneBusAway/onebusaway/wiki">OneBusAway</a>{{/html}} (OBA) software.  While MTA Bus Time's SIRI API is a new addition to the OBA project, OBA does have its own (non-standards-based) RESTful developer API.  MTA Bus Time now exposes a modified version of the OBA RESTful API, as described below.  The primary modification is to exclude all real-time data, which in the context of MTA Bus Time should come from the standards-based SIRI API.

== Documentation ==

The documentation for the OBA RESTful API is available {{html}}<a href="https://developer.onebusaway.org/modules/onebusaway-application-modules/current/api/where/index.html">online</a>{{/html}}.  The modifications to this API with respect to MTA Bus Time are described {{html}}<a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/RESTful-API-Roadmap">here</a>{{/html}}.  This API will allow you to "discover" static/baseline information about the bus services covered under MTA Bus Time.  It is, effectively, a set of web services that gives you convenient HTTP-based access to selected subsets of information otherwise available from the GTFS schedule files.  This API provides, for example:

* The list of routes covered by MTA Bus Time
* Full information about each stop covered by MTA Bus Time (e.g. the lat/lon coordinates, stop name, list of routes serving that stop)
* The stops served by a given route
* The physical geometry for a given route (for mapping and geographic calculations)
* The schedule of trips serving a given stop or route (repeat: //schedule//, having nothing to do with the real-time data)
* The stops or routes near a given location

== Access == 
The root of the OBA API in the MTA Bus Time deployment is ## https://bustime.mta.info/api/where/ ##.  So, for example:

* To get the list of and metadata for the agencies covered by MTA Bus Time, use: {{html}}<a href="https://bustime.mta.info/api/where/agencies-with-coverage.xml?key=YOUR_KEY_HERE">https://bustime.mta.info/api/where/agencies-with-coverage.xml?key=YOUR_KEY_HERE</a>{{/html}}
* To get the list of and metadata for the MTA NYCT and MTABC routes covered by MTA Bus Time, use: {{html}}<a href="https://bustime.mta.info/api/where/routes-for-agency/MTA%20NYCT.xml?key=YOUR_KEY_HERE">https://bustime.mta.info/api/where/routes-for-agency/MTA%20NYCT.xml?key=YOUR_KEY_HERE</a>{{/html}}
* For information on one specific stop served by MTA Bus Time, use: {{html}}<a href="https://bustime.mta.info/api/where/stop/MTA_STOP-ID.xml?key=YOUR_KEY_HERE">https://bustime.mta.info/api/where/stop/MTA_STOP-ID.xml?key=YOUR_KEY_HERE</a>{{/html}}
* For information on the stops that serve a route, use <a href="https://bustime.mta.info/api/where/stops-for-route/MTA%20NYCT_M1.json?key=YOUR_KEY_HERE&includePolylines=false&version=2">https://bustime.mta.info/api/where/stops-for-route/MTA%20NYCT_M1.json?key=YOUR_KEY_HERE&includePolylines=false&version=2</a>{{/html}}
* For information on stops near a location, use {{html}}<a href="https://bustime.mta.info/api/where/stops-for-location.json?lat=40.748433&lon=-73.985656&latSpan=0.005&lonSpan=0.005&key=YOUR_KEY_HERE">https://bustime.mta.info/api/where/stops-for-location.json?lat=40.748433&lon=-73.985656&latSpan=0.005&lonSpan=0.005&key=YOUR_KEY_HERE</a>{{/html}}
* and so on...

Please use the same API key for the OBA API as for the SIRI API.