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:

  1. Sign up for a free WMATA developer account: https://developer.wmata.com/

  2. Log in and subscribe to the free default tier.

  3. Copy the primary or secondary key from your profile.

  4. Pass your API key to a function through one of three ways:

    1. Use Sys.setenv() to temporarily set define WMATA_KEY.

    2. Pass your key as a string to the api_key argument of any function.

    3. 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())

Arguments

api_key

Subscription key which provides access to this API. Defaults Sys.getenv("WMATA_KEY") via wmata_key().

Value

For wmata_key(), a 32 character alphanumeric API key. For wmata_validate(), either TRUE for a valid key or an error if invalid.

Details

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