R/crypto_news.R

Defines functions crypto_news

Documented in crypto_news

#' @title General Cryptocurrency News
#' @description Get general crypto news
#'  
#' @param min_id News ID to get the latest news
#' 
#' @importFrom purrr set_names
#' @importFrom lubridate as_datetime
#' @importFrom dplyr mutate
#' 
#' @return
#' @export
#' 
#' @examples
#' crypto_news()
crypto_news <- function(min_id = 0, ...){
  
  url <- finnhub_endpoint('crypto_news')
  
  retry_get(url, 
            query = list(token = finnhub_key(),
                         category = 'crypto',
                         minId = min_id)) %>% 
    purrr::set_names(c('news_category', 'unixtime', 'headline', 'id', 
                       'image', 'related', 'source', 'summary', 'url')) %>% 
    dplyr::mutate(date = lubridate::as_datetime(unixtime, tz = finnhub_timezone))
}
threadingdata/finnhubr documentation built on Aug. 10, 2020, 12:48 a.m.