Script Name: schedule.php

Supports GET and POST. Equivalent SOAP functions will also be provided. Output formats: XML, JSON, PHP and SOAP. Only XML and JSON will be described here. JSON and PHP will be similarly formatted.

Description

Return schedule block of 5 trips for supplied route id, board stop, alight stop. If ‘next’ indicated, then start schedule with very next schedule adjusted with real-time data if available. When ‘leaving’ at a specific time, schedules are sorted in ascending order. When ‘arriving’ by a specific time, schedules are sorted in descending order.

Input

  • route_id = route id

The route id is an integer.

  • stop_on = stop_id

The origin point  is the boarding stop for the trip.

  • stop_off = stop_id

The destination point is the alighting stop for the trip.

  • day [optional] = sun | mon | tue | wed | thr | fri | sat

The day is the day of the week for the trip, not the date. The day is based on the time criteria value (‘lv’ or ‘ar’). If the day is omitted, the day value is set to the current day.

  • lvar [optional] = lv | ar

This value will determine if the trip is designed around leaving or arriving by the trip time. If this value is omitted, it is automatically set to ‘lv’.

  • hour [optional] = 1 – 12

This is an integer value between 1 and 12. Defaults to ‘now’ if omitted.

  • min [optional] = 0 – 59

This is an integer value between 0 and 59. Defaults to ‘now’ if omitted.

  • ampm [optional] = am | pm

Two character string: ‘am’, or ‘pm’. Defaults to ‘now’ if omitted.

  • next [optional] = y

If set to ‘y’, then time fields are ignored and time is set to ‘now’. Real-time adjustments are made to first time in the list when real-time data is available.

  • format [optional] = xml | json | php

By default output format is set to xml. Optionally, json and php are native array formats.

Returns

Schedule returns: board/alight stop names with associated times. If ‘next’ parameter is set then first trip times will be adjusted with real-time data if available.

Only XML and JSON formats are described here since JSON and PHP are similarly formatted.

Usage

# Required: apikey, stop-on id, stop-off id,
http://developer.metro.net/tm/schedule.php?apikey=1-2-3-4-5&route=419&stop_on=44819&stop_off=15349
# Optional
http://developer.metro.net/tm/schedule.php?apikey=1-2-3-4-5&route=419&stop_on=44819&stop_off=15349&day=MON&hour=9&lvar=AR&format=xml&m=AM