R/api-tiingo.R

Defines functions tiingo_api_key

Documented in tiingo_api_key

#' Set Tiingo API Key
#'
#' @param api_key Optionally passed parameter to set Tiingo `api_key`.
#'
#' @return Returns invisibly the currently set `api_key`
#'
#' @details A wrapper for `riingo::ringo_set_token()`
#'
#' @seealso [tq_get()] `get = "tiingo"`
#'
#'
#' @export
#'
#' @examples
#'
#' \dontrun{
#' tiingo_api_key(api_key = "foobar")
#' }
#'
#' @name tiingo_api_key
#' @export
tiingo_api_key <- function(api_key) {
    if(!requireNamespace("riingo", quietly = TRUE)) {
        stop("riingo must be installed to use this functionality.", call. = FALSE)
    }

    if (missing(api_key)) return(riingo::riingo_get_token())

    riingo::riingo_set_token(api_key)

}

Try the tidyquant package in your browser

Any scripts or data that you put into this service are public.

tidyquant documentation built on April 3, 2023, 5:13 p.m.