A pattern consists of all departures, stops, routes, runs, directions and disruptions associated with a particular run ID. This is returned as a list of tibbles, with output corresponding to their respective API calls.
patterns( run_ref, route_type, stop_id = NULL, departs = Sys.time(), user_id = determine_user_id(), api_key = determine_api_key() )
run_ref | A character run reference. This supersedes the integer
|
---|---|
route_type | Optionally filter results by a route type. A route type can
be provided either as a non-negative integer code, or as a character:
"Tram", "Train", "Bus", "Vline" or "Night Bus". Character inputs are not
case-sensitive. Use the |
stop_id | Integer. Optionally filter results to a specific stop ID.
These can be searched for with the |
departs | POSIXct or character. Optionally filter by date. See Details. Characters are automatically converted to departs, and are assumed to be given as Melbourne time. The behaviour of the API is unpredictable when using this argument --- see details. Defaults to the current system time. |
user_id | Integer or character. A user ID or devid provided by Public
Transport Victoria. Refer to |
api_key | Character. An API key, with dashes, provided by Public
Transport Victoria. Refer to |
An object of class "ptvapi", which is effectively a list with the following names:
departures
stops
routes
runs
directions
disruptions
The stops
tibble has an output similar to that returned by
stops_on_route
. The routes
tibble does not contain service
status information.
Departures: The API seems to return the earliest 7 departures. While
the PTV Timetable API supports filtering patterns by datetimes, the
behaviour of this argument is not reliable --- it appears to filter by day
only, returning the earliest 7 departures of a different day. It is
recommended that departures are retrieved via the departures
function.
if (FALSE) { patterns(run_ref = "1", route_type = 0) patterns(run_ref = "1", route_type = "Train") }