Learn R Programming

qualtRics (version 3.1.6)

qualtrics_api_credentials: Install Qualtrics credentials in your .Renviron file for repeated use

Description

This function adds your Qualtrics API key and base URL to your .Renviron file so it can be called securely without being stored in your code. After you have installed these two credentials, they can be called any time with Sys.getenv("QUALTRICS_API_KEY") or Sys.getenv("QUALTRICS_BASE_URL"). If you do not have an .Renviron file, the function will create one 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

qualtrics_api_credentials(
  api_key,
  base_url,
  overwrite = FALSE,
  install = FALSE
)

Arguments

api_key

The API key provided to you from Qualtrics formatted in quotes. Learn more about Qualtrics API keys at https://api.qualtrics.com/

base_url

The institution-specific base URL for your Qualtrics account, formatted in quotes, without the protocol (do not include https://). Find your base URL at https://api.qualtrics.com/

overwrite

If TRUE, will overwrite existing Qualtrics credentials that you already have in your .Renviron file.

install

If TRUE, will install the key in your .Renviron file for use in future sessions. Defaults to FALSE (single session use).

Examples

Run this code

if (FALSE) {
qualtrics_api_credentials(
  api_key = "",
  base_url = "",
  install = TRUE
)
# Reload your environment so you can use the credentials without restarting R
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("QUALTRICS_API_KEY")

# If you need to overwrite existing credentials:
qualtrics_api_credentials(
  api_key = "",
  base_url = "",
  overwrite = TRUE,
  install = TRUE
)
# Reload your environment to use the credentials
}

Run the code above in your browser using DataLab