Set your IPUMS API key as the value associated with the IPUMS_API_KEY environment variable.

The key can be stored for the duration of your session or for future sessions. If saved for future sessions, it is added to the .Renviron file in your home directory. If you choose to save your key to .Renviron, this function will create a backup copy of the file before modifying.

This function is modeled after the census_api_key() function from tidycensus.

Learn more about the IPUMS API in vignette("ipums-api").

set_ipums_api_key(api_key, save = overwrite, overwrite = FALSE, unset = FALSE)



API key associated with your user account.


If TRUE, save the key for use in future sessions by adding it to the .Renviron file in your home directory. Defaults to FALSE, unless overwrite = TRUE.


If TRUE, overwrite any existing value of IPUMS_API_KEY in the .Renviron file with the provided api_key. Defaults to FALSE.


If TRUE, remove the existing value of IPUMS_API_KEY from the environment and the .Renviron file in your home directory.


The value of api_key, invisibly.

See also

set_ipums_default_collection() to set a default collection.