R/neon_sites.R

Defines functions neon_sites

Documented in neon_sites

#' Table of all NEON sites
#' 
#' Returns a table of all NEON sites by making a single API call
#' to the `/sites` endpoint.
#' @inheritParams neon_download
#' @importFrom httr GET content
#' @export
neon_sites <- function(api = "https://data.neonscience.org/api/v0", 
                       .token = Sys.getenv("NEON_TOKEN")){
  
  resp <- httr::GET(paste0(api, "/sites"), 
                    httr::add_headers("X-API-Token" = .token))
  txt <- httr::content(resp, as="text")
  sites <- jsonlite::fromJSON(txt)[[1]]
  tibble::as_tibble(sites)
}

Try the neonstore package in your browser

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

neonstore documentation built on June 22, 2024, 11:15 a.m.