set_bls_key: Install a BLS API Key in Your '.Renviron' File for Repeated...

View source: R/set_bls_key.R

set_bls_keyR Documentation

Install a BLS API Key in Your .Renviron File for Repeated Use

Description

This function will add your BLS API key to your .Renviron file 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("BLS_KEY") and can be used in package functions by simply typing BLS_KEY. If you do not have an .Renviron file, the function will create on for you. If you already have an .Renviron file, the function will append the key to your existing file, while making a backup of your original file for disaster recovery purposes.

Usage

set_bls_key(key = NA, overwrite = NA)

Arguments

key

The API key provided to you from the BLS formatted in quotes. A key can be acquired at https://data.bls.gov/registrationEngine/

overwrite

If this is set to TRUE, it will overwrite an existing BLS_KEY that you already have in your .Renviron file.

Value

No return value. A convenience function used for API Key configuration.

Examples


## Not run: 
set_bls_key("111111abc")
# First time, reload your environment so you can use the key without restarting R.
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("BLS_KEY")

## End(Not run)

## Not run: 
# If you need to overwrite an existing key:
set_bls_key("111111abc", overwrite = TRUE)
# First time, reload your environment so you can use the key without restarting R.
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("BLS_KEY")

## End(Not run)

blscrapeR documentation built on Sept. 17, 2022, 1:05 a.m.