View source: R/dep_set_api_key.R
| dep_set_api_key | R Documentation |
A wrapper around tidycensus::census_api_key() that
checks for a Census API key using a cascading lookup: (1) the explicit
key argument, (2) the CENSUS_API_KEY environment variable,
(3) an interactive prompt. If no key can be resolved in a non-interactive
session, an informative error is raised.
dep_set_api_key(key = NULL, install = FALSE, overwrite = FALSE)
key |
A character scalar; a Census API key. If |
install |
A logical scalar; if |
overwrite |
A logical scalar; if |
The lookup order is:
If key is provided (non-NULL), it is used directly.
If key is NULL, the function checks
Sys.getenv("CENSUS_API_KEY"). If that is set (non-empty), it is
used.
If neither is available and the session is interactive, the user is prompted to enter their key with setup instructions.
If the session is non-interactive and no key is found, an error is raised with instructions for setting the environment variable.
The Census API key (invisibly), as returned by
tidycensus::census_api_key().
## Not run:
# Use an explicit key (session only)
dep_set_api_key(key = "your_key_here")
# Install key to .Renviron for future sessions
dep_set_api_key(key = "your_key_here", install = TRUE)
# Rely on CENSUS_API_KEY env var or interactive prompt
dep_set_api_key()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.