Title: | Access the 'Public Transport Victoria' Timetable API |
---|---|
Description: | Access the 'Public Transport Victoria' Timetable API <https://www.ptv.vic.gov.au/footer/data-and-reporting/datasets/ptv-timetable-api/>, with results returned as familiar R data structures. Retrieve information on stops, routes, disruptions, departures, and more. |
Authors: | David Neuzerling [aut, cre, cph] |
Maintainer: | David Neuzerling <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.5 |
Built: | 2024-11-14 04:29:15 UTC |
Source: | https://github.com/mdneuzerling/ptvapi |
Accessing the Public Transport Victoria Timetable API reqiures a user ID
(also called a devid
) and an API key. These can be accessed by contacting
Public Transport Victoria. See
https://www.ptv.vic.gov.au/footer/data-and-reporting/datasets/ptv-timetable-api/
The user ID and API key can be entered directly into all functions. Alternatively, all functions will pick up on the PTV_USER_ID and API_KEY environment variables, if defined.
All API requests use SSL by default. To disable this, and to use the http
API endpoints rather than the https
API endpoints, set the option:
options(use_insecure_ptv_connection = TRUE)
This is an unofficial wrapper of the Public Transport Victoria Timetable API. The author(s) of this package are unaffiliated with Public Transport Victoria.
Maintainer: David Neuzerling [email protected] [copyright holder]
Useful links:
## Not run: # tibble of all routes routes() # Search for routes by name (case insensitive, partial matching supported) routes(route_name = "Frankston") # All current disruptions disruptions(disruption_status = "current") # Train stops near Flinders Street Station stops_nearby( latitude = -37.8183, longitude = 144.9671, route_types = "Train" ) # Upcoming train departures from Flinders Street Station departures(stop_id = 1071, route_type = "Train") ## End(Not run)
## Not run: # tibble of all routes routes() # Search for routes by name (case insensitive, partial matching supported) routes(route_name = "Frankston") # All current disruptions disruptions(disruption_status = "current") # Train stops near Flinders Street Station stops_nearby( latitude = -37.8183, longitude = 144.9671, route_types = "Train" ) # Upcoming train departures from Flinders Street Station departures(stop_id = 1071, route_type = "Train") ## End(Not run)
departures
retrieves all upcoming departures for a given stop ID and route
type.
departures( stop_id, route_type, route_id = NULL, direction_id = NULL, platform_numbers = NULL, departs = Sys.time(), look_backwards = FALSE, max_results = 5, include_cancelled = FALSE, validate_results = TRUE, user_id = determine_user_id(), api_key = determine_api_key() )
departures( stop_id, route_type, route_id = NULL, direction_id = NULL, platform_numbers = NULL, departs = Sys.time(), look_backwards = FALSE, max_results = 5, include_cancelled = FALSE, validate_results = TRUE, user_id = determine_user_id(), api_key = determine_api_key() )
stop_id |
An integer stop ID returned by the |
route_type |
A route type which 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
|
route_id |
Optionally filter by a route ID. These can be obtained with
the |
direction_id |
Optionally filter by a direction ID. These can be
obtained with the |
platform_numbers |
Character vector. Optionally filter results by platform number. Despite the name, these are characters. |
departs |
POSIXct or Character. Optionally filter results to departures on or after the given value, according to either scheduled or estimated departure time. Characters are automatically converted to datetimes, and are assumed to be given as Melbourne time. Defaults to the current system time. |
look_backwards |
Boolean. Whether to look before |
max_results |
Integer. The maximum number of departures to return for
each route_id. Departures are ordered by estimated departure time, when
available, and scheduled departure time otherwise. When set to 0, all
departures after the given |
include_cancelled |
Logical. Whether results should be returned if they have been cancelled. Metropolitan train services only. Defaults to FALSE. |
validate_results |
Boolean. If TRUE (the default), will apply additional
filters to ensure that the arguments to |
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 |
Filtering departures: The API supports filtering by departure time,
to show the departures after the given time. However, its behaviour is
unpredictable, returning departures around the given time, both before and
after. We apply an additional filter once the results are retrieved to
ensure that only departures at or after the given departs
datetime are
shown.
It's not clear what functionality look_backwards
has. It's included here
regardless. Moreover, it's not clear how the API treats route_id
or
max_results
. We filter the results after retrieval, to ensure that
departs
, max_results
, and route_id
are respected. This additional
validation can be disabled by setting validate_results = TRUE
.
A tibble consisting of the following columns:
stop_id
route_id
run_id
(deprecated, use run_ref
instead)
run_ref
direction_id
disruption_ids
scheduled_departure
estimated_departure
at_platform
platform_number
flags
departure_sequence
## Not run: departures(stop_id = 1071, route_type = "Train") departures(stop_id = 1071, route_type = 0) departures( stop_id = 1071, route_type = "Train", platform_numbers = c(4, 5) ) departures( stop_id = 1071, route_type = "Train", route_id = 6 ) departures( stop_id = 1071, route_type = "Train", departs = "2020-06-23 17:05:00" ) ## End(Not run)
## Not run: departures(stop_id = 1071, route_type = "Train") departures(stop_id = 1071, route_type = 0) departures( stop_id = 1071, route_type = "Train", platform_numbers = c(4, 5) ) departures( stop_id = 1071, route_type = "Train", route_id = 6 ) departures( stop_id = 1071, route_type = "Train", departs = "2020-06-23 17:05:00" ) ## End(Not run)
This function effectively wraps the results of route_types
to
translate a route type to a human-readable form, such as translating 0
to
"Train"
. This function is not vectorised.
describe_route_type( route_type, user_id = determine_user_id(), api_key = determine_api_key() )
describe_route_type( route_type, user_id = determine_user_id(), api_key = determine_api_key() )
route_type |
Atomic integer or character. |
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 |
character
This function returns all directions with a given ID. Directions that share
an ID are not necessarily related, especially if not filtering by route type.
It's advised to use to the directions_on_route
function to
search for directions of interest.
directions( direction_id, route_type = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
directions( direction_id, route_type = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
direction_id |
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 |
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 |
A tibble consisting of the following columns:
direction_id
direction_name
,
route_id
route_type
route_type_description
route_direction_description
## Not run: directions(direction_id = 5) directions(direction_id = 5, route_type = "Train") directions(direction_id = 5, route_type = 0) ## End(Not run)
## Not run: directions(direction_id = 5) directions(direction_id = 5, route_type = "Train") directions(direction_id = 5, route_type = 0) ## End(Not run)
Directions on a given route
directions_on_route( route_id, user_id = determine_user_id(), api_key = determine_api_key() )
directions_on_route( route_id, user_id = determine_user_id(), api_key = determine_api_key() )
route_id |
Integer. These can be listed and described with the
|
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 |
A tibble consisting of the following columns:
direction_id
direction_name
,
route_id
route_type
route_type_description
route_direction_description
## Not run: directions_on_route(6) ## End(Not run)
## Not run: directions_on_route(6) ## End(Not run)
This function can be used when the integer disruption ID is already known.
This can be searched for with either disruptions
,
disruptions_on_route
, or disruptions_at_stop
functions.
disruption_information( disruption_id, user_id = determine_user_id(), api_key = determine_api_key() )
disruption_information( disruption_id, user_id = determine_user_id(), api_key = determine_api_key() )
disruption_id |
Integer. |
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 |
A tibble with the following columns:
disruption_mode
disruption_mode_description
disruption_id
title
url
description
disruption_status
disruption_type
published_on
last_updated
from_date
to_date
routes
stops
colour
display_on_board
display_status
## Not run: disruption_information(206639) ## End(Not run)
## Not run: disruption_information(206639) ## End(Not run)
Disruption mode types (eg. "metro_train", "metro_tram", "school_bus", "taxi") have corresponding integer IDs. This function retrieves a named vector in which the values are the disruption mode descriptions, and the names of the vector are the description mode numbers. Note that disruption mode names are in snake case, that is, all lower case with underscores between words.
disruption_modes(user_id = determine_user_id(), api_key = determine_api_key())
disruption_modes(user_id = determine_user_id(), api_key = determine_api_key())
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 |
A named vector in which the values are the disruption mode descriptions, and the names of the vector are the description mode numbers.
## Not run: disruption_modes()
## Not run: disruption_modes()
Information for all disruptions
disruptions( route_types = NULL, disruption_modes = NULL, disruption_status = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
disruptions( route_types = NULL, disruption_modes = NULL, disruption_status = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
route_types |
Integer or character vector. Optionally filter by a vector
of route types. 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
|
disruption_modes |
Integer vector. Optionally filter by disruption
modes. For a full list of modes and their corresponding descriptions, use
the |
disruption_status |
Character. Can be used to filter to either "current" or "planned" disruptions. Defaults to NULL, in which case no filter is applied. |
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 |
A tibble with the following columns:
disruption_mode
disruption_mode_description
disruption_id
title
url
description
disruption_status
disruption_type
published_on
last_updated
from_date
to_date
routes
stops
colour
display_on_board
display_status
## Not run: disruptions() disruptions(route_types = c("Train", "Tram")) disruptions(disruption_modes = c(0, 1)) disruptions(disruption_status = "current") ## End(Not run)
## Not run: disruptions() disruptions(route_types = c("Train", "Tram")) disruptions(disruption_modes = c(0, 1)) disruptions(disruption_status = "current") ## End(Not run)
Disruptions at a given stop
disruptions_at_stop( stop_id, disruption_status = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
disruptions_at_stop( stop_id, disruption_status = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
stop_id |
Integer stop ID. |
disruption_status |
Character. Can be used to filter to either "current" or "planned" disruptions. Defaults to NULL, in which case no filter is applied. |
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 |
A tibble with the following columns:
disruption_mode
disruption_mode_description
disruption_id
title
url
description
disruption_status
disruption_type
published_on
last_updated
from_date
to_date
routes
stops
colour
display_on_board
display_status
## Not run: disruptions_at_stop(1071) disruptions_at_stop(1071, disruption_status = "current") ## End(Not run)
## Not run: disruptions_at_stop(1071) disruptions_at_stop(1071, disruption_status = "current") ## End(Not run)
Disruptions on a given route
disruptions_on_route( route_id, stop_id = NULL, disruption_status = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
disruptions_on_route( route_id, stop_id = NULL, disruption_status = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
route_id |
Integer. These can be listed and described with the
|
stop_id |
Integer. Optionally filter results to a specific stop ID.
These can be searched for with the |
disruption_status |
Character. Can be used to filter to either "current" or "planned" disruptions. Defaults to NULL, in which case no filter is applied. |
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 |
A tibble with the following columns:
disruption_mode
disruption_mode_description
disruption_id
title
url
description
disruption_status
disruption_type
published_on
last_updated
from_date
to_date
routes
stops
colour
display_on_board
display_status
## Not run: disruptions_on_route(6) disruptions_on_route(6, stop_id = 1071) disruptions_on_route(6, disruption_status = "current") ## End(Not run)
## Not run: disruptions_on_route(6) disruptions_on_route(6, stop_id = 1071) disruptions_on_route(6, disruption_status = "current") ## End(Not run)
Retrieve fare information for a journey through the given zones. Also supports journey touch on and off times, to accommodate for discounts.
fare_estimate( min_zone, max_zone, journey_touch_on = NULL, journey_touch_off = NULL, journey_in_free_tram_zone = FALSE, travelled_route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
fare_estimate( min_zone, max_zone, journey_touch_on = NULL, journey_touch_off = NULL, journey_in_free_tram_zone = FALSE, travelled_route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
min_zone |
Integer. Minimum zone travelled through. |
max_zone |
Integer. Maximum zone travelled through. |
journey_touch_on , journey_touch_off
|
POSIXct or Character. Optionally filter results to a journey time. Values to both must be provided. Characters are automatically converted to datetimes, and are assumed to be given as Melbourne time. |
journey_in_free_tram_zone |
Boolean. Defaults to |
travelled_route_types |
Integer or character vector. Optionally filter
by a vector of route types. 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
|
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 |
A data frame consisting of one row for each passenger_type
, and the
following columns:
min_zone
max_zone
unique_zones
early_bird
free_tram_zone
weekend_journey
passenger_type
fare_2_hour_peak
fare_2_hour_off_peak
fare_daily_peak
fare_daily_off_peak
pass_7_days
pass_28_to_69_day_per_day
pass_70_plus_day_per_day
weekend_cap
holiday_cap
## Not run: fare_estimate(min_zone = 1, max_zone = 2) fare_estimate(min_zone = 1, max_zone = 1, journey_in_free_tram_zone = TRUE) fare_estimate( min_zone = 1, max_zone = 2, travelled_route_types = c("Train", "Tram") ) fare_estimate( min_zone = 1, max_zone = 2, journey_touch_on = "2020-06-21 07:31:00", journey_touch_off = "2020-06-21 08:45:00" ) ## End(Not run)
## Not run: fare_estimate(min_zone = 1, max_zone = 2) fare_estimate(min_zone = 1, max_zone = 1, journey_in_free_tram_zone = TRUE) fare_estimate( min_zone = 1, max_zone = 2, travelled_route_types = c("Train", "Tram") ) fare_estimate( min_zone = 1, max_zone = 2, journey_touch_on = "2020-06-21 07:31:00", journey_touch_off = "2020-06-21 08:45:00" ) ## End(Not run)
Information for all outlets
outlets(user_id = determine_user_id(), api_key = determine_api_key())
outlets(user_id = determine_user_id(), api_key = determine_api_key())
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 |
The outlet_name
reported here is more accurately described as an outlet
address. We keep the outlet_name
column name as this is how the PTV API
describes it.
The business hours are reported as characters. Usually they take on a format of "8.00AM - 10.00PM", but there variants such as "7.30AM - 11.00AM and 1.30PM - 6.00PM". For days on which an outlet is closed, the opening hours are usually reported as "CLOSED", but can also be an empty character. Some opening hours are "24 Hours". These fields are also filled with missing values and empty characters.
A tibble with the following columns:
outlet_slid_spid
outlet_name
outlet_business
outlet_latitude
outlet_longitude
outlet_suburb
outlet_postcode
outlet_business_hour_mon
outlet_business_hour_tue
outlet_business_hour_wed
outlet_business_hour_thu
outlet_business_hour_fri
outlet_business_hour_sat
outlet_business_hour_sun
outlet_notes
## Not run: outlets() ## End(Not run)
## Not run: outlets() ## End(Not run)
Information for outlets near a given location
outlets_nearby( latitude, longitude, max_distance = NULL, max_results = 30, user_id = determine_user_id(), api_key = determine_api_key() )
outlets_nearby( latitude, longitude, max_distance = NULL, max_results = 30, user_id = determine_user_id(), api_key = determine_api_key() )
latitude |
Numeric. Latitude in decimal degrees. For example, Flinders Street Station is at approximately -37.8183 latitude. |
longitude |
Numeric. Longitude in decimal degrees. For example, Flinders Street Station is at approximately 144.9671 longitude. |
max_distance |
Integer. Optionally filter by maximum distance from the given location, in metres. |
max_results |
Integer. Defaults to 30. Caps the number of results returned. |
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 |
The outlet_name
reported here is more accurately described as an outlet
address. We keep the outlet_name
column name as this is how the PTV API
describes it.
The business hours are reported as characters. Usually they take on a format of "8.00AM - 10.00PM", but there variants such as "7.30AM - 11.00AM and 1.30PM - 6.00PM". For days on which an outlet is closed, the opening hours are usually reported as "CLOSED", but can also be an empty character. Some opening hours are "24 Hours". These fields are also filled with missing values and empty characters.
A tibble with the following columns:
outlet_slid_spid
outlet_name
outlet_business
outlet_latitude
outlet_longitude
outlet_suburb
outlet_postcode
outlet_business_hour_mon
outlet_business_hour_tue
outlet_business_hour_wed
outlet_business_hour_thu
outlet_business_hour_fri
outlet_business_hour_sat
outlet_business_hour_sun
outlet_notes
## Not run: outlets_nearby(latitude = -37.8183, longitude = 144.9671) ## End(Not run)
## Not run: outlets_nearby(latitude = -37.8183, longitude = 144.9671) ## End(Not run)
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() )
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 |
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.
An object of class "ptvapi", which is effectively a list with the following names:
departures
stops
routes
runs
directions
disruptions
## Not run: patterns(run_ref = "1", route_type = 0) patterns(run_ref = "1", route_type = "Train") ## End(Not run)
## Not run: patterns(run_ref = "1", route_type = 0) patterns(run_ref = "1", route_type = "Train") ## End(Not run)
Information for a given route
route_information( route_id, include_geopath = FALSE, geopath_utc = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
route_information( route_id, include_geopath = FALSE, geopath_utc = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
route_id |
Integer. These can be listed and described with the
|
include_geopath |
Logical. Whether to populate the |
geopath_utc |
Date, or character that can be converted to a date. The
UTC date for which the geopaths are effective. Defaults to the current
date. Has no effect if |
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 |
A tibble of routes, with the following columns:
route_id
route_gtfs_id
route_name
route_type
route_type_description
route_number
geopath
service_status
service_status_timestamp
## Not run: route_information(6) route_information(6, include_geopath = TRUE) route_information(6, include_geopath = TRUE, geopath_utc = "2020-07-01") ## End(Not run)
## Not run: route_information(6) route_information(6, include_geopath = TRUE) route_information(6, include_geopath = TRUE, geopath_utc = "2020-07-01") ## End(Not run)
Route types (tram, train, etc.) are provided to the PTV API as an integer code. This function retrieves a named vector in which the values are the route type descriptions, and the names of the vector are the route type numbers. Note that "Night Bus" is a separate route type.
route_types(user_id = determine_user_id(), api_key = determine_api_key())
route_types(user_id = determine_user_id(), api_key = determine_api_key())
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 |
A named integer vector in which the values are the route type descriptions, and the names of the vector are the route type numbers.
## Not run: route_types() ## End(Not run)
## Not run: route_types() ## End(Not run)
Information for all routes
routes( route_types = NULL, route_name = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
routes( route_types = NULL, route_name = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
route_types |
Integer or character vector. Optionally filter by a vector
of route types. 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
|
route_name |
Character. Optionally filter by route name. Partial matches are accepted, and the matches are not case sensitive. |
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 |
A tibble of routes, with the following columns:
route_id
route_gtfs_id
route_name
route_type
route_type_description
route_number
geopath
service_status
service_status_timestamp
## Not run: routes() routes(route_types = "Train") routes(route_types = 0) routes(route_types = c("Train", "Tram")) routes(route_name = "Frankston") routes(route_name = "Craigie") routes(route_name = "werribee") ## End(Not run)
## Not run: routes() routes(route_types = "Train") routes(route_types = 0) routes(route_types = c("Train", "Tram")) routes(route_name = "Frankston") routes(route_name = "Craigie") routes(route_name = "werribee") ## End(Not run)
Run IDs are not unique across the network. If you are interested in a
specific run, consider supplying a value to the optional route_type
argument.
run_information( run_ref, route_type = NULL, include_geopath = FALSE, geopath_utc = NULL, date_utc = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
run_information( run_ref, route_type = NULL, include_geopath = FALSE, geopath_utc = NULL, date_utc = NULL, 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 |
include_geopath |
Logical. Whether to populate the |
geopath_utc |
Date, or character that can be converted to a date. The
UTC date for which the geopaths are effective. Defaults to the current
date. Has no effect if |
date_utc |
Date, or character that can be converted to a date. The UTC date for which the results are effective. Defaults to the current date. It's uncertain how much historical or future-dated data is available. This argument is experimental and seems to not be functioning. |
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 |
A tibble with the following columns:
run_id
(deprecated, use run_ref
instead)
run_ref
route_id
route_type
route_type_description
direction_id
run_sequence
final_stop_id
destination_name
status
express_stop_count
vehicle_position
vehicle_descriptor
geopath
## Not run: run_information("100") run_information("100", include_geopath = TRUE) run_information("100", include_geopath = TRUE, geopath_utc = "2020-07-01") run_information("100", date_utc = "2020-07-01") ## End(Not run)
## Not run: run_information("100") run_information("100", include_geopath = TRUE) run_information("100", include_geopath = TRUE, geopath_utc = "2020-07-01") run_information("100", date_utc = "2020-07-01") ## End(Not run)
Runs on a given route
runs_on_route( route_id, route_type = NULL, date_utc = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
runs_on_route( route_id, route_type = NULL, date_utc = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
route_id |
Integer. These can be listed and described with the
|
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 |
date_utc |
Date, or character that can be converted to a date. The UTC date for which the results are effective. Defaults to the current date. It's uncertain how much historical or future-dated data is available. This argument is experimental and seems to not be functioning. |
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 |
A tibble with the following columns:
run_id
(deprecated, use run_ref
instead)
run_ref
route_id
route_type
route_type_description
direction_id
run_sequence
final_stop_id
destination_name
status
express_stop_count
vehicle_position
vehicle_descriptor
geopath
## Not run: runs_on_route(6) runs_on_route(6, route_type = "Train") runs_on_route(6, route_type = 0) ## End(Not run)
## Not run: runs_on_route(6) runs_on_route(6, route_type = "Train") runs_on_route(6, route_type = 0) ## End(Not run)
This function will search outlets in which the search term can be found in either the outlet name, outlet business or outlet suburb. The search is case-insensitive. The search term must contain at least 3 characters, and cannot be numeric.
search_outlets( search_term, latitude = NULL, longitude = NULL, max_distance = NULL, route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
search_outlets( search_term, latitude = NULL, longitude = NULL, max_distance = NULL, route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
search_term |
Character. Term used to perform search. |
latitude |
Numeric. Latitude in decimal degrees. For example, Flinders Street Station is at approximately -37.8183 latitude. |
longitude |
Numeric. Longitude in decimal degrees. For example, Flinders Street Station is at approximately 144.9671 longitude. |
max_distance |
Integer. Optionally filter by maximum distance from the given location, in metres. |
route_types |
Integer or character vector. Optionally filter by a vector
of route types. 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
|
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 |
A tibble with the following columns:
outlet_slid_spid
outlet_name
outlet_business
outlet_latitude
outlet_longitude
outlet_suburb
outlet_postcode
outlet_business_hour_mon
outlet_business_hour_tue
outlet_business_hour_wed
outlet_business_hour_thu
outlet_business_hour_fri
outlet_business_hour_sat
outlet_business_hour_sun
outlet_notes
## Not run: search_outlets("St Kilda") search_outlets("St Kilda", route_types = c("Train", "Tram")) search_outlets("St Kilda", route_types = 1) search_outlets( "St Kilda", latitude = -37.867647, longitude = 144.976809 ) search_outlets( "St Kilda", latitude = -37.867647, longitude = 144.976809, max_distance = 100 ) ## End(Not run)
## Not run: search_outlets("St Kilda") search_outlets("St Kilda", route_types = c("Train", "Tram")) search_outlets("St Kilda", route_types = 1) search_outlets( "St Kilda", latitude = -37.867647, longitude = 144.976809 ) search_outlets( "St Kilda", latitude = -37.867647, longitude = 144.976809, max_distance = 100 ) ## End(Not run)
This function will search routes in which the search term can be found in
one of many fields, such as route_id
, route_gtfs_id
, or route_name
.
The search is case-insensitive. Unlike search_stops
and
search_outlets
, this function supports searching for numerics,
and has no minimum character requirement for search_term
.
search_routes( search_term, latitude = NULL, longitude = NULL, max_distance = NULL, route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
search_routes( search_term, latitude = NULL, longitude = NULL, max_distance = NULL, route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
search_term |
Character. Term used to perform search. |
latitude |
Numeric. Latitude in decimal degrees. For example, Flinders Street Station is at approximately -37.8183 latitude. |
longitude |
Numeric. Longitude in decimal degrees. For example, Flinders Street Station is at approximately 144.9671 longitude. |
max_distance |
Integer. Optionally filter by maximum distance from the given location, in metres. |
route_types |
Integer or character vector. Optionally filter by a vector
of route types. 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
|
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 |
A tibble of routes, with the following columns:
route_id
route_gtfs_id
route_name
route_type
route_type_description
route_number
geopath
service_status
service_status_timestamp
## Not run: search_routes("Pakenham") search_routes("Pakenham", route_types = c("Train", "Tram")) search_routes("Pakenham", route_types = 1) search_routes( "Pakenham", latitude = -38.077877, longitude = 145.484751 ) search_routes( "Pakenham", latitude = -38.077877, longitude = 145.484751, max_distance = 100 ) ## End(Not run)
## Not run: search_routes("Pakenham") search_routes("Pakenham", route_types = c("Train", "Tram")) search_routes("Pakenham", route_types = 1) search_routes( "Pakenham", latitude = -38.077877, longitude = 145.484751 ) search_routes( "Pakenham", latitude = -38.077877, longitude = 145.484751, max_distance = 100 ) ## End(Not run)
This function will search stops in which the search term can be found in either the stop name or the stop suburb. The search is case-insensitive. The search term must contain at least 3 characters, and cannot be numeric.
search_stops( search_term, latitude = NULL, longitude = NULL, max_distance = NULL, route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
search_stops( search_term, latitude = NULL, longitude = NULL, max_distance = NULL, route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
search_term |
Character. Term used to perform search. |
latitude |
Numeric. Latitude in decimal degrees. For example, Flinders Street Station is at approximately -37.8183 latitude. |
longitude |
Numeric. Longitude in decimal degrees. For example, Flinders Street Station is at approximately 144.9671 longitude. |
max_distance |
Integer. Optionally filter by maximum distance from the given location, in metres. |
route_types |
Integer or character vector. Optionally filter by a vector
of route types. 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
|
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 |
A tibble with the following columns:
stop_id
stop_name
stop_suburb
route_type
route_type_description
stop_sequence
stop_latitude
stop_longitude
disruption_ids
## Not run: search_stops("Ascot Vale") search_stops("Ascot Vale", route_types = c("Train", "Tram")) search_stops("Ascot Vale", route_types = 1) search_stops( "Ascot Vale", latitude = -37.774240, longitude = 144.915518 ) search_stops( "Ascot Vale", latitude = -37.774240, longitude = 144.915518, max_distance = 100 ) ## End(Not run)
## Not run: search_stops("Ascot Vale") search_stops("Ascot Vale", route_types = c("Train", "Tram")) search_stops("Ascot Vale", route_types = 1) search_stops( "Ascot Vale", latitude = -37.774240, longitude = 144.915518 ) search_stops( "Ascot Vale", latitude = -37.774240, longitude = 144.915518, max_distance = 100 ) ## End(Not run)
This function can be used when integer stop ID is already known. This can be
searched for with either the stops_on_route
or
stops_nearby
functions.
stop_information( stop_id, route_type, user_id = determine_user_id(), api_key = determine_api_key() )
stop_information( stop_id, route_type, user_id = determine_user_id(), api_key = determine_api_key() )
stop_id |
Integer stop ID. |
route_type |
A route type which 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
|
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 |
A single-row tibble with the following columns:
stop_id
stop_name
route_type
route_type_description
station_details_id
station_type
station_description
point_id
mode_id
operating_hours
flexible_stop_opening_hours
stop_contact
stop_ticket
stop_location
stop_amenities
stop_accessibility
stop_staffing
disruption_ids
Stops near a given location
stops_nearby( latitude, longitude, max_distance = NULL, route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
stops_nearby( latitude, longitude, max_distance = NULL, route_types = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
latitude |
Numeric. Latitude in decimal degrees. For example, Flinders Street Station is at approximately -37.8183 latitude. |
longitude |
Numeric. Longitude in decimal degrees. For example, Flinders Street Station is at approximately 144.9671 longitude. |
max_distance |
Integer. Optionally filter by maximum distance from the given location, in metres. |
route_types |
Integer or character vector. Optionally filter by a vector
of route types. 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
|
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 |
A tibble with the following columns:
stop_id
stop_name
stop_suburb
route_type
route_type_description
stop_sequence
stop_latitude
stop_longitude
disruption_ids
## Not run: stops_nearby(latitude = -37.8183, longitude = 144.9671) stops_nearby(latitude = -37.8183, longitude = 144.9671, max_distance = 1000) stops_nearby( latitude = -37.8183, longitude = 144.9671, route_types = c("Train", "Tram") ) stops_nearby( latitude = -37.8183, longitude = 144.9671, route_types = 0 ) ## End(Not run)
## Not run: stops_nearby(latitude = -37.8183, longitude = 144.9671) stops_nearby(latitude = -37.8183, longitude = 144.9671, max_distance = 1000) stops_nearby( latitude = -37.8183, longitude = 144.9671, route_types = c("Train", "Tram") ) stops_nearby( latitude = -37.8183, longitude = 144.9671, route_types = 0 ) ## End(Not run)
Stops on a given route and route type
stops_on_route( route_id, route_type, direction_id = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
stops_on_route( route_id, route_type, direction_id = NULL, user_id = determine_user_id(), api_key = determine_api_key() )
route_id |
Integer. These can be listed and described with the
|
route_type |
A route type which 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
|
direction_id |
Optionally filter by a direction ID. These can be
obtained with the |
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 |
A tibble with the following columns:
stop_id
stop_name
stop_suburb
route_type
route_type_description
stop_sequence
stop_latitude
stop_longitude
disruption_ids
## Not run: stops_on_route(6, route_type = "Train") stops_on_route(6, route_type = 0) ## End(Not run)
## Not run: stops_on_route(6, route_type = "Train") stops_on_route(6, route_type = 0) ## End(Not run)