get_gt_api_key: Read the GOOGLE TRENDS FOR HEALTH API Key

View source: R/helpers.R

get_gt_api_keyR Documentation

Read the GOOGLE TRENDS FOR HEALTH API Key

Description

This function will read your GOOGLE TRENDS FOR HEALTH API key from the environment variables. 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 recovery purposes.

Usage

get_gt_api_key(key = NULL)

Arguments

key

The API key from your Google Developer project authorized for Google Trends for Health API use, formatted in quotes. A key can be acquired by requesting access at https://support.google.com/trends/contact/trends_api and following the setup instructions.

Value

Returns the API key that is set in the GOOGLE_TRENDS_FOR_HEALTH_API_KEY environment variable.

Examples


tryCatch(
  get_gt_api_key(),
  error = function(e) cat("You need to set up a valid key")
)


gtrendshealth documentation built on June 17, 2025, 9:12 a.m.