Get/set openrouteservice API key.

ors_api_key(key, service = "openrouteservice", username = NULL, keyring = NULL)

Arguments

key

API key value provided as a character scalar

service

Service name, a character scalar.

username

Username, a character scalar, or NULL if the key is not associated with a username.

keyring

For systems that support multiple keyrings, specify the name of the keyring to use here. If NULL, then the default keyring is used. See also has_keyring_support().

Value

API Key value when called without key.

Details

To set the key provide it in the key argument. To retrieve the current value call the function with key unset.

Typically the key is saved in the system credential store. Once the key is defined, it persists in the keyring store of the operating system so it doesn't need to be set again in a new R session.

Internally the function uses \link[keyring]{key_set} and \link[keyring]{key_get}. The use of keyring package can be bypassed by providing the key in the environment variable ORS_API_KEY. The value from the environment variable takes precedence over the value stored in the system credential store. The default environment variable name used to retrieve the openrouteservice api key can be overridden by specifying it in options("openrouteservice.api_key_env").

Author

Andrzej Oleś andrzej.oles@gmail.com