SMSMyBus exposes its data via a programming interface. This page describes that interface.

This portion of the web service describes scheduling information. Under all circumstances, this is predictive data. It is based on the real-time information described by the Metro system for each route - not fixed schedule information.

It's important to understand that the API is dependent on the Metro's scheduling service. If the Metro's service is down, so are we. I'm going to do my best to differentiate the difference between "no buses running" and "service unavailable" but there are no guarantees.


getarrivals

Overview

The getarrivals method will return real-time arrival estimates for the next N buses at a specified stop. Several filters can be applied to narrow the results.

URL

http://api.smsmybus.com/v1/getarrivals

Fields

Name Value Description
key String (required) API access key
stopID String A four-digit value describing a valid stop in the Metro system.
routeID String A two-digit value describing a valid route in the Metro system. If routeID is specified, either stopID or vehicleID must also be specified in the request.
vehicleID String A three-digit value describing a valid bus vehicle in the Metro system. If vehicleID is specified, routeID must also be specified in the request.

Examples

Retrieve the arrival estimates for all buses traveling through stop 1101:

http://api.smsmybus.com/v1/getarrivals?key=xxx&stopID=1101

Retrieve the arrival estimates for route 19 buses traveling through stop 1101:

http://api.smsmybus.com/v1/getarrivals?key=xxx&stopID=1101&routeID=19

Retrieve the arrival estimates for future stops of the route 19 bus identifies as #915:

http://api.smsmybus.com/v1/getarrivals?key=xxx&routeID=19&vehicleID=915

Response

The response length is dependent on the particular request parameters. If the status field is 0, the response will be grouped by stop and each stop will be grouped by routes traveling through the respective stop.

The following results example is for a single stopID.

{ "status" : "0", "timestamp" : "12:38pm", "stop" : { "stopID" : "1101", "route" : [{ "routeID" : "4", "vehicleID" : "993", "human" : "Route 4 toward STP arrives in 10 minutes", "minutes" : "10", "arrivalTime" : "12:44pm", "destination" : "STP", }, { "routeID" : "3", "vehicleID" : "433", "human" : "Route 3 toward ETP arrives in 12 minutes", "minutes" : "12", "arrivalTime" : "12:46pm", "destination" : "ETP", }, ... ... ]}, ... ... }

If a vehicleID is specified, multiple stops will be returned.

Error

An error is indicated by a non-zero status value. If the status value is non-zero, the description field will be present describing the error in plain English.

{ "status" : "-1", "description" : "Invalid request parameters", }