R/list-regions.R

Defines functions ial_regions

Documented in ial_regions

#' List of all the regions (districts) with display name and id
#'
#' @md
#' @return data frame
#' @note As of 2018-09-30 this is a broken endpoint on their server
#' @export
ial_regions <- function() {

  httr::GET(
    url = "http://api.nightlights.io/regions",
    httr::user_agent("indialights R package / <gitlab/hrbrmstr/indialights>")
  ) -> res

  httr::stop_for_status(res)

  xdat <- httr::content(res, as="text")
  xdat <- jsonlite::fromJSON(xdat)

  class(xdat) <- c("tbl_df", "tbl", "data.frame")

  xdat

}
hrbrmstr/indialights documentation built on Oct. 1, 2018, 12:24 a.m.