Title: | Washington Metropolitan Area Transit Authority API |
---|---|
Description: | The Washington Metropolitan Area Transit Authority is a government agency operating light rail and passenger buses in the Washington D.C. area. With a free developer account, access their 'Metro Transparent Data Sets API' <https://developer.wmata.com/> to return data frames of transit data for easy analysis. |
Authors: | Kiernan Nicholls [aut, cre, cph]
|
Maintainer: | Kiernan Nicholls <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.9.3 |
Built: | 2025-02-05 02:39:15 UTC |
Source: | https://github.com/k5cents/metro |
Returns a set of buses scheduled at a stop for a given date.
bus_departs(StopID, Date = NULL, api_key = wmata_key())
bus_departs(StopID, Date = NULL, api_key = wmata_key())
StopID |
7-digit regional stop ID. |
Date |
(Optional) Date for which to retrieve route and stop information. |
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble with 1 row per bus departure and 8 variables:
7-digit regional ID which can be used in various bus-related
Date and time (UTC) when the bus is scheduled to stop at this location.
Denotes a binary direction (0 or 1) of the bus. There
is no specific mapping to direction, but a different value for the same
route signifies that the buses are traveling in opposite directions. Use
the TripDirectionText
column to show the actual destination of the bus.
Scheduled start date and time (UTC) for this trip.
Scheduled end date and time (UTC) for this trip.
Bus route variant identifier (pattern). This variant can be used in several other bus methods which accept variants. Note that customers will never see anything other than the base route name, so variants 10A, 10Av1, 10Av2, etc. will be displayed as 10A on the bus.
General direction of the trip (e.g.: NORTH, SOUTH, EAST, WEST).
Destination of the bus.
Trip identifier. This can be correlated with the data in our bus schedule information as well as bus positions.
Data frame containing scheduled arrival information.
Other Bus Route and Stop Methods:
bus_path()
,
bus_position()
,
bus_routes()
,
bus_schedule()
,
bus_stops()
## Not run: bus_departs(1001195, Sys.Date()) ## End(Not run)
## Not run: bus_departs(1001195, Sys.Date()) ## End(Not run)
Returns a set of reported bus incidents/delays for a given Route. Omit the Route to return all reported items.
bus_incidents(Route = NULL, api_key = wmata_key())
bus_incidents(Route = NULL, api_key = wmata_key())
Route |
Base bus route; variations are not recognized (i.e.: C2 instead of C2v1, C2v2, etc.). |
api_key |
Subscription key which provides access to this API. Defaults
|
A data frame with 1 row per incident and 5 variables:
Unique identifier for an incident.
Free-text description of the incident type. Usually
Delay
or Alert
but is subject to change at any time.
Character string of routes affected. Routes listed are usually identical to base route names (i.e.: not 10Av1 or 10Av2, but 10A), but may differ from what our bus methods return.
Free-text description of the delay or incident.
Date and time (UTC) of last update.
Note that the Route parameter accepts only base route names and no variations, i.e.: use 10A instead of 10Av1 and 10Av2.
Data frame of bus incidents and delays.
Other Incident APIs:
elevator_incidents()
,
rail_incidents()
## Not run: bus_incidents() ## End(Not run)
## Not run: bus_incidents() ## End(Not run)
For a given date, returns the set of ordered latitude/longitude points along a route variant along with the list of stops served.
bus_path(RouteID, Date = NULL, api_key = wmata_key())
bus_path(RouteID, Date = NULL, api_key = wmata_key())
RouteID |
Bus route variant, e.g.: 70, 10A, 10Av1. |
Date |
Date for which to retrieve route and stop information. Uses
today's date if |
api_key |
Subscription key which provides access to this API. Defaults
|
A list with 4 elements:
Bus route variant.
Descriptive name for the route.
The coordinate path of the line in both directions.
The coordinates of stops on a given line.
A list with (1) set of ordered latitude/longitude points along a route variant along with (2) the list of stops served.
Other Bus Route and Stop Methods:
bus_departs()
,
bus_position()
,
bus_routes()
,
bus_schedule()
,
bus_stops()
## Not run: bus_path("70") ## End(Not run)
## Not run: bus_path("70") ## End(Not run)
Returns bus positions for the given route, with an optional search radius. If no parameters are specified, all bus positions are returned.
bus_position( RouteId = NULL, Lat = NULL, Lon = NULL, Radius = NULL, api_key = wmata_key() )
bus_position( RouteId = NULL, Lat = NULL, Lon = NULL, Radius = NULL, api_key = wmata_key() )
RouteId |
Base bus route, e.g.: 70, 10A. |
Lat |
Center point Latitude, required if Longitude and Radius are specified. |
Lon |
Center point Longitude, required if Latitude and Radius are specified. |
Radius |
Radius (meters) to include in the search area. If |
api_key |
Subscription key which provides access to this API. Defaults
|
A data frame with 1 row per bus and 13 variables:
Unique identifier for the bus. This is usually visible on the bus itself.
Last reported Latitude of the bus.
Last reported Longitude of the bus.
Distance (meters) of the bus from the provided search
coordinates. Calculated using geodist::geodist()
and the "cheap ruler"
method.
Deviation, in minutes, from schedule. Positive values indicate that the bus is running late while negative ones are for buses running ahead of schedule.
Date and time (UTC) of last position update.
Unique trip ID. This can be correlated with the data returned from the schedule-related methods.
Base route name as shown on the bus. Note that the base route name could also refer to any variant, so a RouteID of 10A could refer to 10A, 10Av1, 10Av2, etc.
General direction of the trip, not the bus itself (e.g.: NORTH, SOUTH, EAST, WEST).
Destination of the bus.
Scheduled start date and time (UTC) of the bus's current trip.
Scheduled end date and time (UTC) of the bus's current trip.
Note that the RouteID
parameter accepts only base route names and no
variations, i.e.: use 10A instead of 10Av1 or 10Av2.
Data frame containing bus position information.
Other Bus Route and Stop Methods:
bus_departs()
,
bus_path()
,
bus_routes()
,
bus_schedule()
,
bus_stops()
## Not run: bus_position("70", 38.8895, -77.0353) ## End(Not run)
## Not run: bus_position("70", 38.8895, -77.0353) ## End(Not run)
Returns a list of all bus route variants (patterns). For example, the 10A and 10Av1 are the same route, but may stop at slightly different locations.
bus_routes(api_key = wmata_key())
bus_routes(api_key = wmata_key())
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble with 3 variables and one row per route variant:
Unique identifier for a given route variant. Can be used in various other bus-related methods.
Descriptive name of the route variant.
Denotes the route variant's grouping - lines are a combination of routes which lie in the same corridor and which have significant portions of their paths along the same roadways.
Data frame containing route variant information
Other Bus Route and Stop Methods:
bus_departs()
,
bus_path()
,
bus_position()
,
bus_schedule()
,
bus_stops()
## Not run: bus_routes() ## End(Not run)
## Not run: bus_routes() ## End(Not run)
Returns schedules for a given route variant for a given date.
bus_schedule( RouteID, IncludingVariations = TRUE, Date = NULL, api_key = wmata_key() )
bus_schedule( RouteID, IncludingVariations = TRUE, Date = NULL, api_key = wmata_key() )
RouteID |
Bus route variant, e.g.: 70, 10A, 10Av1, etc. |
IncludingVariations |
Whether or not to include variations if a base
route is specified in RouteID. For example, if B30 is specified and
|
Date |
(Optional) Date for which to retrieve route and stop information. |
api_key |
Subscription key which provides access to this API. Defaults
|
A data frame with 1 row per trip and 10 variables:
Bus route variant. This can be used in several other bus methods which accept variants.
General direction of the trip (NORTH, SOUTH, EAST, WEST, LOOP, etc.).
Descriptive text of where the bus is headed. This is similar, but not necessarily identical, to what is displayed on the bus.
Scheduled start date and time (UTC) for this trip.
Scheduled end date and time (UTC) for this trip.
Unique trip ID. This can be correlated with the data returned from the schedule-related methods.
7-digit regional ID which can be used in various bus-related
methods. If unavailable, the StopID
will be 0 or NA
Stop name. May be slightly different from what is spoken or displayed in the bus.
Order of the stop in the sequence of StopTimes.
Scheduled departure date and time (UTC) from this stop.
Data frame containing trip information
Other Bus Route and Stop Methods:
bus_departs()
,
bus_path()
,
bus_position()
,
bus_routes()
,
bus_stops()
## Not run: bus_schedule("70") ## End(Not run)
## Not run: bus_schedule("70") ## End(Not run)
Returns a list of nearby bus stops based on latitude, longitude, and radius. Omit all parameters to retrieve a list of all stops.
bus_stops(Lat = NULL, Lon = NULL, Radius = NULL, api_key = wmata_key())
bus_stops(Lat = NULL, Lon = NULL, Radius = NULL, api_key = wmata_key())
Lat |
Center point Latitude, required if |
Lon |
Center point Longitude, required if |
Radius |
Radius (meters) to include in the search area, required if
|
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble with 1 row per stop and 6 variables:
String array of route variants which provide service at this stop. Note that these are not date-specific; any route variant which stops at this stop on any day will be listed.
Stop name. May be slightly different from what is spoken or displayed in the bus.
Latitude.
Longitude.
Distance (meters) of the stop from the provided search
coordinates. Calculated using geodist::geodist()
and the "cheap ruler"
method.
Character string of route variants which provide service at this stop. Note that these are not date-specific; any route variant which stops at this stop on any day will be listed.
Data frame containing stop information
Other Bus Route and Stop Methods:
bus_departs()
,
bus_path()
,
bus_position()
,
bus_routes()
,
bus_schedule()
## Not run: bus_stops(38.8895, -77.0353, 500) ## End(Not run)
## Not run: bus_stops(38.8895, -77.0353, 500) ## End(Not run)
Elevator/Escalator Outages
elevator_incidents(StationCode = NULL, api_key = wmata_key())
elevator_incidents(StationCode = NULL, api_key = wmata_key())
StationCode |
Station code. Use |
api_key |
Subscription key which provides access to this API. Defaults
|
A data frame with 1 row per incident and 9 variables:
Unique identifier for unit, by type (a single elevator and
escalator may have the same UnitName
, but no two elevators or two
escalators will have the same UnitName
).
Type of unit. Will be ELEVATOR
or ESCALATOR
.
Unit's station code. Use this value in other rail-related APIs to retrieve data about a station.
Full station name, may include entrance information (e.g.: Metro Center, G and 11th St Entrance).
Free-text description of the unit location within a station (e.g.: Escalator between mezzanine and platform).
Description for why the unit is out of service or otherwise in reduced operation.
Date and time (UTC) unit was reported out of service.
Date and time (UTC) outage details was last updated.
Estimated date and time (UTC) by when unit is expected to return to normal service. May be NULL.
Note that for stations with multiple platforms and therefore StationCodes
(e.g.: Metro Center, L'Enfant Plaza, etc.), a distinct call is required for
each StationCode
.
Data frame of reported elevator and escalator outages.
Other Incident APIs:
bus_incidents()
,
rail_incidents()
## Not run: elevator_incidents() ## End(Not run)
## Not run: elevator_incidents() ## End(Not run)
All WMATA Rail Lines
metro_lines
metro_lines
A tibble with 6 rows and 6 variables:
Two-letter abbreviation for the line (e.g.: RD, BL, YL, OR, GR, or SV).
Full name of line color.
Start station code. For example, will be F11 (Branch Avenue) for the Green Line, A15 (Shady Grove) for the Red Line, etc. Use this value in other rail-related APIs to retrieve data about a station.
End station code. For example, will be E10 (Greenbelt) for the Green Line, B11 (Glenmont) for the Red Line, etc. Use this value in other rail-related APIs to retrieve data about a station.
Intermediate terminal station code(s). During
normal service, some trains on some lines might end their trip prior to the
StartStationCode
or EndStationCode.
A good example is on the Red Line
where some trains stop at A11 (Grosvenor) or B08 (Silver Spring). NA
if
not defined.
As of 2021-02-22 22:00:00 ET.
All WMATA Bus Routes
metro_routes
metro_routes
A tibble 322 rows and 3 variables:
Unique identifier for a given route variant. Can be used in various other bus-related methods.
Descriptive name of the route variant.
Denotes the route variant's grouping - lines are a combination of routes which lie in the same corridor and which have significant portions of their paths along the same roadways.
As of 2021-02-22 22:00:00 ET.
All WMATA Rail Stations
metro_stations
metro_stations
A tibble with 95 rows and 10 variables:
Station code for this station. Use this value in other rail-related APIs to retrieve data about a station.
Full name for this station, as shown on the WMATA website.
For stations with multiple platforms (e.g.: Gallery
Place, Fort Totten, L'Enfant Plaza, and Metro Center), the additional
StationCode
will be listed here.
Character vector of two-letter abbreviations (e.g.: RD,
BL, YL, OR, GR, or SV) served by this station. If the station has an
additional platform, the lines served by the other platform are listed in
the LineCodes
values for the record associated with the StationCode
found in StationTogether.
Latitude.
Longitude.
Street address (for GPS use).
City.
State (abbreviated).
Zip code.
As of 2021-02-22 22:00:00 ET.
All WMATA Bus Stops
metro_stops
metro_stops
A tibble with 9,044 rows and 5 variables:
String array of route variants which provide service at this stop. Note that these are not date-specific; any route variant which stops at this stop on any day will be listed.
Stop name. May be slightly different from what is spoken or displayed in the bus.
Latitude.
Longitude.
Character string of route variants which provide service at this stop. Note that these are not date-specific; any route variant which stops at this stop on any day will be listed.
As of 2021-02-22 22:00:00 ET.
Returns next bus arrival times at a stop.
next_bus(StopID, api_key = wmata_key())
next_bus(StopID, api_key = wmata_key())
StopID |
7-digit regional stop ID. |
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per arrival with 8 variables:
7-digit regional ID which can be used in various bus-related
methods. If unavailable, the StopID
will be 0 or NA
Stop name. May be slightly different from what is spoken or displayed in the bus.
Base route name as shown on the bus. This can be used in other bus-related methods. Note that all variants will be shown as their base route names (i.e.: 10Av1 and 10Av2 will be shown as 10A).
Customer-friendly description of direction and destination for a bus.
Denotes a binary direction (0 or 1) of the bus. There is no specific mapping to direction, but a different value for the same route signifies that the buses are traveling in opposite directions. Use the DirectionText element to show the actual destination of the bus.
Minutes until bus arrival at this stop. Numeric value.
Bus identifier. This can be correlated with results returned from bus positions.
Trip identifier. This can be correlated with the data in our bus schedule information as well as bus positions.
Data frame of bus arrivals.
Other Real-Time Predictions:
next_train()
## Not run: next_bus(StopID = "1001195") ## End(Not run)
## Not run: next_bus(StopID = "1001195") ## End(Not run)
Returns next train arrival information for one or more stations. Will return
an empty set of results when no predictions are available. Use "All" for the
StationCodes
parameter to return predictions for all stations.
next_train(StationCodes = NULL, api_key = wmata_key())
next_train(StationCodes = NULL, api_key = wmata_key())
StationCodes |
Character vector of station codes. For all predictions,
use |
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per arrival with 9 variables:
Number of cars on a train, usually 6 or 8, but might also NA
.
Abbreviated version of the final destination for a train. This is similar to what is displayed on the signs at stations.
Destination station code. Can be NA
. Use this
value in other rail-related APIs to retrieve data about a station.
When DestinationCode
is populated, this is the
full name of the destination station, as shown on the WMATA website.
Denotes the track this train is on, but does not necessarily equate to Track 1 or Track 2. With the exception of terminal stations, predictions at the same station with different Group values refer to trains on different tracks.
Two-letter abbreviation for the line (e.g.: RD, BL, YL, OR, GR,
or SV). May also be NA
for trains with no passengers.
Station code for where the train is arriving. Useful
when passing in All as the StationCodes
parameter. Use this value in
other rail-related APIs to retrieve data about a station.
Full name of the station where the train is arriving.
Useful when passing in "All" as the StationCodes
parameter.
Minutes until arrival. Can be a numeric value, 0 (arriving),
-1 (boarding), or NA
.
For terminal stations (e.g.: Greenbelt, Shady Grove, etc.), predictions may be displayed twice.
Some stations have two platforms (e.g.: Gallery Place, Fort Totten, L'Enfant Plaza, and Metro Center). To retrieve complete predictions for these stations, be sure to pass in both StationCodes.
For trains with no passengers, the DestinationName
will be "No Passenger".
Data frame of train arrivals.
Other Real-Time Predictions:
next_bus()
## Not run: next_train(StationCodes = c("A02", "B02")) ## End(Not run)
## Not run: next_train(StationCodes = c("A02", "B02")) ## End(Not run)
Check if data has length and rows
no_data_now(x)
no_data_now(x)
x |
A data frame or list to check |
no_data_now(data.frame()) no_data_now(data.frame(a = 1))
no_data_now(data.frame()) no_data_now(data.frame(a = 1))
Returns a distance, fare information, and estimated travel time between any two stations, including those on different lines. Omit both parameters to retrieve data for all stations.
rail_destination( FromStationCode = NULL, ToStationCode = NULL, api_key = wmata_key() )
rail_destination( FromStationCode = NULL, ToStationCode = NULL, api_key = wmata_key() )
FromStationCode |
Station code for the origin station. Use the
|
ToStationCode |
Station code for the destination station. Use the
|
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per with variables:
Origin station code. Use this value in other rail-related APIs to retrieve data about a station.
Destination station code. Use this value in other rail-related APIs to retrieve data about a station.
Average of distance traveled between two stations and straight-line distance (as used for WMATA fare calculations). For more details, please refer to WMATA's Tariff on Fares.
Estimated travel time (schedule time) in minutes between
the source and destination station. This is not correlated to minutes
(Min
) in Real-Time Rail Predictions.
Fare during peak times (weekdays from opening to 9:30 AM and 3-7 PM (EST), and weekends from midnight to closing).
Fare during off-peak times (times other than the ones described below).
Reduced fare for senior citizens or people with disabilities.
A data frame containing station to station information
Other Rail Station Information:
rail_entrance()
,
rail_lines()
,
rail_path()
,
rail_stations()
,
rail_times()
,
station_info()
## Not run: rail_destination("A01", "A08") ## End(Not run)
## Not run: rail_destination("A01", "A08") ## End(Not run)
Returns a list of nearby station entrances based on latitude, longitude, and radius (meters). Omit search parameters to return all station entrances.
rail_entrance(Lat = NULL, Lon = NULL, Radius = NULL, api_key = wmata_key())
rail_entrance(Lat = NULL, Lon = NULL, Radius = NULL, api_key = wmata_key())
Lat |
(Optional) Center point Latitude, required if |
Lon |
(Optional) Center point Longitude, required if |
Radius |
(Optional) Radius (meters) to include in the search area,
required if |
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per entrance with 7 variables:
Name of the entrance (usually the station name and nearest intersection).
The station code associated with this entrance. Use this value in other rail-related APIs to retrieve data about a station.
For stations containing multiple platforms (e.g.:
Gallery Place, Fort Totten, L'Enfant Plaza, and Metro Center), the other
station code (previously StationCode2
).
Additional information for the entrance, if available.
Currently available data usually shows the same value as the Name
element.
Latitude.
Longitude.
Distance (meters) of the entrance from the provided search
coordinates. Calculated using geodist::geodist()
and the "cheap ruler"
method.
A data frame of station entrances.
Other Rail Station Information:
rail_destination()
,
rail_lines()
,
rail_path()
,
rail_stations()
,
rail_times()
,
station_info()
## Not run: rail_entrance(38.8895, -77.0353) ## End(Not run)
## Not run: rail_entrance(38.8895, -77.0353) ## End(Not run)
Reported rail incidents (significant disruptions and delays to normal service). The data is identical to WMATA's Metrorail Service Status feed.
rail_incidents(api_key = wmata_key())
rail_incidents(api_key = wmata_key())
api_key |
Subscription key which provides access to this API. Defaults
|
A data frame with 1 row incident and 5 variables:
Unique identifier for an incident.
Free-text description of the incident.
Free-text description of the incident type. Usually Delay or Alert but is subject to change at any time.
Character vector of line codes (e.g.: RD; or BL; OR; or BL; OR; RD;).
Date and time (UTC) of last update.
Data frame of all rail incidents.
Other Incident APIs:
bus_incidents()
,
elevator_incidents()
## Not run: rail_incidents() ## End(Not run)
## Not run: rail_incidents() ## End(Not run)
Returns information about all rail lines.
rail_lines(api_key = wmata_key())
rail_lines(api_key = wmata_key())
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per line with 6 variables:
Two-letter abbreviation for the line (e.g.: RD, BL, YL, OR, GR, or SV).
Full name of line color.
Start station code. For example, will be F11 (Branch Avenue) for the Green Line, A15 (Shady Grove) for the Red Line, etc. Use this value in other rail-related APIs to retrieve data about a station.
End station code. For example, will be E10 (Greenbelt) for the Green Line, B11 (Glenmont) for the Red Line, etc. Use this value in other rail-related APIs to retrieve data about a station.
Intermediate terminal station code(s). During
normal service, some trains on some lines might end their trip prior to the
StartStationCode
or EndStationCode.
A good example is on the Red Line
where some trains stop at A11 (Grosvenor) or B08 (Silver Spring). NA
if
not defined.
A data frame of rail lines.
Other Rail Station Information:
rail_destination()
,
rail_entrance()
,
rail_path()
,
rail_stations()
,
rail_times()
,
station_info()
## Not run: rail_lines() ## End(Not run)
## Not run: rail_lines() ## End(Not run)
Returns a set of ordered stations and distances between two stations on the same line.
rail_path(FromStationCode, ToStationCode, api_key = wmata_key())
rail_path(FromStationCode, ToStationCode, api_key = wmata_key())
FromStationCode |
Station code for the origin station. Use the Station List method to return a list of all station codes. |
ToStationCode |
Station code for the destination station. Use the Station List method to return a list of all station codes. |
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per arrival with 6 variables:
Two-letter abbreviation for the line (e.g.: RD, BL, YL, OR, GR, or SV) this station's platform is on.
Station code for this station. Use this value in other rail-related APIs to retrieve data about a station.
Full name for this station, as shown on the WMATA website.
Ordered sequence number.
Distance in meters to the previous station in the
list, ordered by SeqNum
. Converted from feet, rounded to the nearest
meter.
Note that this method is not suitable on its own as a pathfinding solution between stations.
A data frame of stations on rail path.
Other Rail Station Information:
rail_destination()
,
rail_entrance()
,
rail_lines()
,
rail_stations()
,
rail_times()
,
station_info()
## Not run: rail_path("A01", "A08") ## End(Not run)
## Not run: rail_path("A01", "A08") ## End(Not run)
Returns uniquely identifiable trains in service and what track circuits they currently occupy. Will return an empty set of results when no positions are available.
rail_positions(api_key = wmata_key())
rail_positions(api_key = wmata_key())
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble with 1 row per train and 9 variables:
Uniquely identifiable internal train identifier.
Non-unique train identifier, often used by WMATA's Rail Scheduling and Operations Teams, as well as over open radio communication.
Number of cars. Can sometimes be 0 when there is no data available.
The direction of movement regardless of which track the train is on. Valid values are 1 or 2. Generally speaking, trains with direction 1 are northbound/eastbound, while trains with direction 2 are southbound/westbound.
The circuit identifier the train is currently on. This identifier can be referenced from the Standard Routes method.
Destination station code. Can be NA
. Use
this value in other rail-related APIs to retrieve data about a station.
Note that this value may sometimes differ from the destination station
code returned by our Next Trains methods.
Two-letter abbreviation for the line (e.g.: RD, BL, YL, OR,
GR, or SV). May also be NA
in certain cases.
Approximate "dwell time". This is not an exact value, but can be used to determine how long a train has been reported at the same track circuit.
Service Type of a train, can be any of the following Service Types:
NoPassengers
: This is a non-revenue train with no passengers on board.
Note that this designation of NoPassengers
does not necessarily
correlate with PIDS "No Passengers". As of 08/22/2016, this functionality
has been reinstated to include all non-revenue vehicles, with minor
exceptions.
Normal
: This is a normal revenue service train.
Special
: This is a special revenue service train with an unspecified
line and destination. This is more prevalent during scheduled track
work.
Unknown
: This often denotes cases with unknown data or work vehicles.
Please refer to this page for additional details.
A data frame of train positions.
Other Train Positions:
standard_routes()
,
track_circuits()
## Not run: rail_positions() ## End(Not run)
## Not run: rail_positions() ## End(Not run)
Returns a list of station location and address information based on a given
LineCode
. Use NULL
(default) to return all stations. The response is an
data frame identical to that returned in the Station Information method.
rail_stations(LineCode = NULL, api_key = wmata_key())
rail_stations(LineCode = NULL, api_key = wmata_key())
LineCode |
Two-letter line code abbreviation, or
|
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per station with 10 variables:
Station code for this station. Use this value in other rail-related APIs to retrieve data about a station.
Full name for this station, as shown on the WMATA website.
For stations with multiple platforms (e.g.: Gallery
Place, Fort Totten, L'Enfant Plaza, and Metro Center), the additional
StationCode
will be listed here.
Character vector of two-letter abbreviations (e.g.: RD,
BL, YL, OR, GR, or SV) served by this station. If the station has an
additional platform, the lines served by the other platform are listed in
the LineCodes
values for the record associated with the StationCode
found in StationTogether.
Latitude.
Longitude.
Street address (for GPS use).
City.
State (abbreviated).
Zip code.
A data frame of stations on a rail line.
Other Rail Station Information:
rail_destination()
,
rail_entrance()
,
rail_lines()
,
rail_path()
,
rail_times()
,
station_info()
## Not run: rail_stations("RD") ## End(Not run)
## Not run: rail_stations("RD") ## End(Not run)
Returns opening and scheduled first/last train times based on a given
StationCode
. Omit the StationCode
to return timing information for all
stations.
rail_times(StationCode = NULL, api_key = wmata_key())
rail_times(StationCode = NULL, api_key = wmata_key())
StationCode |
Station code. Use the |
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per train with 8 variables:
Station code for this station. Use this value in other rail-related APIs to retrieve data about a station.
Full name of the station.
Station code for the train's destination. Use this value in other rail-related APIs to retrieve data about a station.
Day of the week abbreviation. From list element names.
Station opening time. Converted to hms
class with
hms::parse_hm()
, representing seconds since midnight of that Weekday
.
First train leaves the station at this time (ET).
Converted to hms
class with hms::parse_hm()
, representing seconds since
midnight of that Weekday
.
Last train leaves the station at this time (ET). Converted
to hms
class with hms::parse_hm()
, representing seconds since midnight
of that Weekday
. For times that were in the AM of the next Weekday
,
time is greater than 24 hours.
Note that for stations with multiple platforms (e.g.: Metro Center, L'Enfant
Plaza, etc.), a distinct call is required for each StationCode
to retrieve
the full set of train times at such stations.
A tidy data frame of station schedules. Combined from a nested list of weekday times.
Other Rail Station Information:
rail_destination()
,
rail_entrance()
,
rail_lines()
,
rail_path()
,
rail_stations()
,
station_info()
## Not run: rail_times("A01") ## End(Not run)
## Not run: rail_times("A01") ## End(Not run)
Returns an ordered list of mostly revenue (and some lead) track circuits, arranged by line and track number. This data does not change frequently and should be cached for a reasonable amount of time.
standard_routes()
standard_routes()
A nested tibble with 1 row per track and 3 variables:
Abbreviation for the revenue line. Note that this also includes YLRP (Yellow Line Rush Plus).
Track number (1 or 2).
Array containing ordered track circuit information:
CircuitId
: An internal system-wide uniquely identifiable circuit
number.
SeqNum
: Order in which the circuit appears for the given line and
track. Sequences go from West to East and South to North.
StationCode
: If the circuit is at a station, this value will represent
the station code. Otherwise, it will be be NA
. Use this value in other
rail-related APIs to retrieve data about a station.
Please refer to this page for additional details.
A nested data frame of track circuits.
Other Train Positions:
rail_positions()
,
track_circuits()
## Not run: standard_routes() ## End(Not run)
## Not run: standard_routes() ## End(Not run)
Returns station location and address information based on a given
StationCode
. Similar to rail_stations()
, but returns data on a given
station(s) rather than all stations on a line.
station_info(StationCode, api_key = wmata_key())
station_info(StationCode, api_key = wmata_key())
StationCode |
A character vector of one or more station codes. A separate call is made to the API for each code, do not provide more than 10. |
api_key |
Subscription key which provides access to this API. Defaults
|
A tibble 1 row per station with 10 variables:
Station code for this station. Use this value in other rail-related APIs to retrieve data about a station.
Full name for this station, as shown on the WMATA website.
For stations with multiple platforms (e.g.: Gallery
Place, Fort Totten, L'Enfant Plaza, and Metro Center), the additional
StationCode
will be listed here.
Character vector of two-letter abbreviations (e.g.: RD,
BL, YL, OR, GR, or SV) served by this station. If the station has an
additional platform, the lines served by the other platform are listed in
the LineCodes
values for the record associated with the StationCode
found in StationTogether.
Latitude.
Longitude.
Street address (for GPS use).
City.
State (abbreviated).
Zip code.
A data frame of stations.
Other Rail Station Information:
rail_destination()
,
rail_entrance()
,
rail_lines()
,
rail_path()
,
rail_stations()
,
rail_times()
## Not run: station_info(StationCode = c("A07", "B07")) ## End(Not run)
## Not run: station_info(StationCode = c("A07", "B07")) ## End(Not run)
Returns a list of all track circuits including those on pocket tracks and crossovers. Each track circuit may include references to its right and left neighbors.
track_circuits()
track_circuits()
A nested tibble with 1 row per train and 9 variables:
Track number. 1 and 2 denote "main" lines, while 0 and 3 are connectors (between different types of tracks) and pocket tracks, respectively.
An internal system-wide uniquely identifiable circuit number.
Data frame containing track circuit neighbor information. Note that some track circuits have no neighbors in one direction. All track circuits have at least one neighbor.
NeighborType
: Left or Right neighbor group. Generally speaking, left
neighbors are to the west and south, while right neighbors are to the
east/north.
CircuitIds
: Data frame containing neighboring circuit IDs as list
column.
Please refer to this page for additional details.
A data frame of nested track circuit information.
Other Train Positions:
rail_positions()
,
standard_routes()
## Not run: track_circuits() ## End(Not run)
## Not run: track_circuits() ## End(Not run)
All calls to the WMATA API must be accompanied by a personal API key. A free key can be obtained by subscribing to the default tier:
Sign up for a free WMATA developer account: https://developer.wmata.com/
Log in and subscribe to the free default tier.
Copy the primary or secondary key from your profile.
Pass your API key to a function through one of three ways:
Use Sys.setenv()
to temporarily set define WMATA_KEY
.
Pass your key as a string to the api_key
argument of any function.
Store the the WMATA key as a line like WMATA_KEY=xxxyyyzzz
in your
.Renviron
file, to be called by wmata_key()
via Sys.getenv()
.
The WMATA also provides a demonstration key. This key should never be used in production applications, it is rate limited and subject to change at any time. The key can be found on the WMATA products page when not signed into a developer account.
The wmata_validate()
function can be used to verify a key is valid.
wmata_key(api_key = Sys.getenv("WMATA_KEY")) wmata_validate(api_key = wmata_key())
wmata_key(api_key = Sys.getenv("WMATA_KEY")) wmata_validate(api_key = wmata_key())
api_key |
Subscription key which provides access to this API. Defaults
|
Default tier sufficient for most casual developers. Rate limited to 10 calls/second and 50,000 calls per day. This product contains 8 APIs and all APIs needed for the functions in this package:
Bus Route and Stop Methods
GTFS (unused)
Incidents
Misc Methods
Rail Station Information
Real-Time Bus Predictions
Real-Time Rail Predictions
Train Positions
For wmata_key()
, a 32 character alphanumeric API key. For
wmata_validate()
, either TRUE
for a valid key or an error if invalid.