R/fetch_cd_competitions.R

Defines functions fetch_cd_comps

Documented in fetch_cd_comps

#' Fetch Champion Data Competitions List
#'
#' Retrieves the list of competitions from Champion Data MC API.
#'
#' @return A tibble containing competition details.
#' @export
fetch_cd_comps <- function() {
  url <- "https://mc.championdata.com/data/competitions.json"
  
  comps_raw <- tryCatch(
    jsonlite::fromJSON(url),
    error = function(e) {
      cli::cli_warn("Failed to fetch Champion Data competitions: {e$message}")
      return(NULL)
    }
  )
  
  if (is.null(comps_raw)) {
    return(tibble::tibble())
  }
  
  comps_tbl <- tibble::as_tibble(comps_raw[["competitionDetails"]]$competition)
  
  return(comps_tbl)
}

Try the nrlR package in your browser

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

nrlR documentation built on Sept. 1, 2025, 9:07 a.m.