Setup

You can install the development version from GitHub with:

# install.packages("devtools")
library(devtools)
devtools::install_github("etam4260/dolr")

The US Department of Labor requires users to gain an access key before querying their systems. You must go to https://devtools.dol.gov/developer and make an account.

From there you need to make a new token. Make sure to save the token somewhere as you will only be able to view it once. However, you can use it as many times as you want. You can now supply the ‘key’ argument to the function calls. However, it is NOT RECOMMENDED to do this. Rather, to reduce the need to supply the key argument in every function call, you can use the Sys.setenv() function to save the key to the user environment.

Key Setup

There are various method of setting up a key. However, I recommend using THE Sys.setenv() function. You can also choose to save it into your .Rprofile or .Renviron files.

Using Sys.setenv() during an interactive session

One method of setting the API key is to use environment variables. This library searches for DOL_KEY in the user environment to check if a key has been defined. If no key has been defined, an empty string is outputted.

library(dolr)

Sys.getenv("DOL_KEY")

To set the key…

Sys.setenv("DOL_KEY" = "2yeuduhq72ueajk")
Sys.getenv("DOL_KEY")

To check whether dolr can gain access to this environment variable…

dol_get_key()

It is now setup for the rest of the R session.