Skip to content

Instantly share code, notes, and snippets.

@scascketta
Last active November 21, 2015 22:28
Show Gist options
  • Select an option

  • Save scascketta/42007e0e08faf703d4e6 to your computer and use it in GitHub Desktop.

Select an option

Save scascketta/42007e0e08faf703d4e6 to your computer and use it in GitHub Desktop.
Using OneBusAway API

Using OneBusAway API

API Docs

All calls to OBA require a key, you can just use TEST to start with.

Nearby Trips

Get the trips that are nearby a location:

/api/where/trips-for-location.json?key=TEST&lat=47.653&lon=-122.307&latSpan=0.008&lonSpan=0.008

Example:

http://api.tampa.onebusaway.org/api/where/trips-for-location.json?key=TEST&lat=27.9681&lon=-82.4764&latSpan=0.08&lonSpan=0.08

Params

  • lat, lon - Your location
  • latSpan, lonSpan (bounding box around your location provided above)

The response has a list of the nearby trips accessible as data.list. The ID for these trips are named tripId.

Get the arrival times for a trip:

/api/where/trip-details/<trip_id>.json?key=TEST

Example:

http://api.tampa.onebusaway.org/api/where/trip-details/Hillsborough%20Area%20Regional%20Transit_102717.json?key=TEST

Get a list of arrival times from the response:

data.entry.schedule.stopTimes

NOTE: The arrival times listed are just the seconds after the serviceDate (which is listed in milliseconds). So to compute the actual arrival time in milliseconds, do ((serviceDate / 1000) + arrivalTime) * 1000.

Agency

Info for agencies is included in most responses from OBA as a list in responses at data.references.agencies.

You can also call:

/api/where/agency/<agency-id>.json?key=TEST

Example:

http://api.tampa.onebusaway.org/api/where/agency/Hillsborough%20Area%20Regional%20Transit.json?key=TEST

Nearby Routes

Get nearby routes:

/api/where/routes-for-location.json?key=TEST&lat=27.9681&lon=-82.4764&latSpan=0.08&lonSpan=0.08

Example:

http://api.tampa.onebusaway.org/api/where/routes-for-location.json?key=TEST&lat=27.9681&lon=-82.4764&latSpan=0.08&lonSpan=0.08

Get the route data from a response at data.list.

Arrival Times for Stop

/api/where/arrivals-and-departures-for-stop/<stop-id>.json?key=TEST

Get the predicted (based on real-time data not scheduled data) at data.entry.arrivalsAndDepartures[i].predictedArrivalTime.

Example:

http://api.tampa.onebusaway.org/api/where/arrivals-and-departures-for-stop/Hillsborough%20Area%20Regional%20Transit_6891.json?key=TEST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment