aemet_api_key: Install an AEMET API Key

View source: R/aemet_api_key.R

aemet_api_keyR Documentation

Install an AEMET API Key

Description

This function will store your AEMET API key on your local machine so it can be called securely without being stored in your code. After you have installed your key, it can be called any time by typing Sys.getenv("AEMET_API_KEY") and can be used in package functions by simply typing AEMET_API_KEY.

Alternatively, you can install the API Key manually:

  • Run Sys.setenv(AEMET_API_KEY = "Your_Key"). You would need to run this command on each session (Similar to install = FALSE).

  • Write this line on your .Renviron file: AEMET_API_KEY = "Your_Key" ( same behavior than install = TRUE). This would store your API key permanently.

Usage

aemet_api_key(apikey, overwrite = FALSE, install = FALSE)

Arguments

apikey

The API key provided to you from the AEMET formatted in quotes. A key can be acquired at https://opendata.aemet.es/centrodedescargas/inicio.

overwrite

If this is set to TRUE, it will overwrite an existing AEMET_API_KEY that you already have in local machine.

install

if TRUE, will install the key in your local machine for use in future sessions. Defaults to FALSE.

Value

None

Note

To locate your API Key on your local machine, run rappdirs::user_cache_dir("climaemet", "R").

See Also

Other aemet_auth: aemet_detect_api_key()

Examples

# Don't run these examples!

if (FALSE) {
  aemet_api_key("111111abc", install = TRUE)

  # You can check it with:
  Sys.getenv("AEMET_API_KEY")
}

if (FALSE) {
  # If you need to overwrite an existing key:
  aemet_api_key("222222abc", overwrite = TRUE, install = TRUE)

  # You can check it with:
  Sys.getenv("AEMET_API_KEY")
}

climaemet documentation built on March 18, 2022, 7:01 p.m.