-
Notifications
You must be signed in to change notification settings - Fork 76
#API
The API consists of three feeds: 1) a Transitime JSON/XML feed intended for user interface applications; 2) GTFS-realtime feed for large applications such as Google; and 3) SIRI feed simply because it is considered a standard.
ApiApplication class also specifies which package contains all the root-resource classes that specify the individual commands. There is a separate root-resource class for each of the feeds.
The ApiApplication class indicates that the application path is "v1" which means that the URIs for the feed are the application name, "v1", and then what is specified in the root-resource classes. Each command requires an application key and an agency. This means that URIs will be something like /api/V1/key/TEST_KEY/agency/sfmta/command/predictionsByLoc
where "api" is the webapp application name.
##Transitime XML/JSON commands.
Note: you must set the Accept: header in the request. Otherwise the API will return Error 400 Bad Request. This is true even if you set the format query string parameter to json or xml. Browsers automatically set the Accept header but wget does not so you have to use wget --header='Accept: application/xml'
URL.
Default output is in JSON. Can specify XML by setting the accept header in the request to "application/xml" or by adding format=xml to the query string.
The vehicle command for outputting location and other information for vehicles. In query string can optionally specify list of vehicles or of routes. Can specify vehicle IDs via v=123&v=456&etc
. Can specify route via route IDs or route short names using for example r=2341&r=9382
etc . If vehicles or routes not specified then data for all vehicles for agency is returned.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/vehicles?OPTIONS
The vehiclesDetails command for outputting location and other information for vehicles. Includes additional information such as block assignment information. In query string can optionally specify list of vehicles or of routes. Can specify vehicle IDs via v=123&v=456&etc
. Can specify route via route IDs or route short names using for example r=2341&r=9382
etc. If vehicles or routes not specified then data for all vehicles for agency is returned.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/vehiclesDetails?OPTIONS
The predictions command for outputting prediction information for a set of stops. Need to specify list of route/stops to get predictions for. Can specify route via route IDs or the route short name. Each route/stop is separated by the "|" character so for example the query string could have rs=43|2029&rs=43|3029
Can optionally specify maximum number of predictions via numPreds=2
command. Default numPreds is 3.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/predictions?OPTIONS
The predictionsByLoc command for outputting prediction information for stops near a specified latitude/longitude. Query string parameters include lat & lon such as lat=37.3824&lon=-122.391945
. Can also optionally specify maximum distance in meters nearest stop on route can be from lat/lon, such as maxDistance=1200
. Default value is 1200 meters. Can optionally specify maximum number of predictions via numPreds=2
command. Default numPreds is 3.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/predictionsByLoc?OPTIONS
Same as the per agency predictionsByLoc command but this one will determine the appropriate agencies automatically. For outputting prediction information for stops near a specified latitude/longitude. Query string parameters include lat & lon such as lat=37.3824&lon=-122.391945
. Can also optionally specify maximum distance in meters nearest stop on route can be from lat/lon, such as maxDistance=1200
. Default value is 1200 meters. Can optionally specify maximum number of predictions via numPreds=2
command. Default numPreds is 3.
http://DOMAIN/api/v1/key/TEST_KEY/command/predictionsByLoc?OPTIONS
The routes command for outputting list of routes for agency.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/routes?OPTIONS
The route command for outputting detailed information for specified routes. You can specify the route using either the route ID or the route short name as in r=XX
.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/route?OPTIONS
The stops command for outputting list of stops for each direction for a route. Specify the route ID or the route short name for the desired route using an option in the form r=XX
.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/stops?OPTIONS
The block command for outputting detailed information for specified block assignment, including information for each trip with schedule times. Need to specify block ID and service ID using for example blockId=1234&serviceId=2
.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/block?OPTIONS
The trip command for outputting detailed information for specified trip, including schedule information. Specify trip ID using for example tripId=43213
.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/trip?OPTIONS
The tripPatterns command for outputting trip pattern information for specified route. Specify the route via route ID or the route short name, such as r=38
.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/tripPatterns?OPTIONS
The agencies command for outputting GTFS information for the agency. Note that with each GTFS based system can actually be for multiple agencies.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/agencies?OPTIONS
##GTFS-realtime commands.
vehiclePositions command for outputting vehicle location information in GTFS-realtime format. Can use query string option format=human
for human readable output.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/gtfs-rt/vehiclePositions?OPTIONS
The tripUpdates command for outputting prediction information in GTFS-realtime format. Can use query string option format=human
for human readable output.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/gtfs-rt/tripUpdates?OPTIONS
##SIRI commands.
The vehicleMonitoring command for outputting vehicle information in SIRI format. In query string can optionally specify vehicle IDs via v=123&v=456
etc and route via the route ID or the route short name using r=2341&r=9382
etc . If vehicles nor routes specified then data is returned for all vehicles for agency.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/siri/vehicleMonitoring?OPTIONS
The stopMonitoring command for outputting prediction information in SIRI format. In query string need to specify route and stop. Can specify route via route ID or the route short name via an option such as r=2341 . Specify stop ID via s=1234
. Can optionally specify maximum number of predictions via numPreds=2
command. Default numPreds is 3.
http://DOMAIN/api/v1/key/TEST_KEY/agency/sfmta/command/siri/vehicleMonitoring?OPTIONS