Skip to contents

Get and set the API key used to make requests to the Epidata API. Without a key, requests may be subject to rate limits and other limitations.

Usage

get_api_key()

save_api_key()

Value

For get_api_key(), returns the current API key as a string, or "" if none is set.

Details

We recommend you register for an API key. While most endpoints are available without one, there are limits on API usage for anonymous users, including a rate limit (for V5, 60 requests/hour, plus 5 requests/minute for epidata_archive() and 3 requests/minute for epidata_snapshot(); see the V5 documentation). If you regularly request large amounts of data, please consider registering for an API key.

API keys are strings read from the environment variable DELPHI_EPIDATA_KEY. We recommend setting your key with save_api_key(), which will open your .Renviron file in a text editor. You will need to write DELPHI_EPIDATA_KEY=yourkeyhere (without quotes) in the file and save it. Once the .Renviron file has been saved as instructed, it will be read automatically when you start future R sessions (see ?Startup for details on .Renviron files). Alternatively, you can modify the environment variable at the command line before/while launching R, or inside an R session with Sys.setenv(), but these will not persist across sessions.

The key is stored as plain text, so treat the .Renviron file like a password: if it lives in a project directory, make sure it is excluded from version control (e.g. by listing .Renviron in .gitignore). If you would rather not keep the key in a file, you can read it from an encrypted store such as the keyring package and pass it to Sys.setenv() in your .Rprofile.

Once an API key is set, it is automatically used for all requests made by functions in this package.