R/http_client.R

Defines functions bd_request

# Internal function to abstact away HTTP requests.

bd_request <- function(
  endpoint = ? typed::Character(length = 1),
  query = list() ? typed::List()) {

  base_url <- "https://basedosdados.org/api/3/action/bd_"
  target_endpoint <- paste0(base_url, endpoint)

  httr::GET(
    target_endpoint,
    encode = 'json',
    query = query) %>%
    httr::content() %>%
    purrr::pluck("result")

}

Try the basedosdados package in your browser

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

basedosdados documentation built on March 7, 2023, 6:26 p.m.