Skip to contents

These functions read and set the YouTube API key in the current R process.

Usage

yt_get_key()
yt_set_key(key)

Arguments

key

A character vector specifying a YouTube API key.

Value

`yt_get_key()` returns `YOUTUBE_KEY` invisibly, or `NULL` when it is unset.

`yt_set_key()` sets `YOUTUBE_KEY` for the current R process and invisibly returns the key. Put the variable in a user-level `.Renviron` file yourself if it must persist across sessions. In continuous integration, supply it from the service's secret store as an environment variable.

Examples

if (FALSE) { # \dontrun{
yt_set_key("YOUR_YOUTUBE_API_KEY")
yt_get_key()

list_channel_videos(
  channel_id = "UCDgj5-mFohWZ5irWSFMFcng",
  max_results = 3,
  auth = "key"
)
} # }