R/get_tables.R

Defines functions get_tables

Documented in get_tables

#' Retrieve available tables
#'
#' \code{get_tables} retrieves the names of the available tables of the Swiss Parliament WebServices.
#'
#' @importFrom jsonlite fromJSON
#' @importFrom dplyr pull
#' @importFrom magrittr "%>%"
#'
#' @return A character vector that contains all the names of the available tables.
#'
#' @export
#'
#' @examples
#' \dontrun{
#' # Get all available tables
#' get_tables()
#' }
get_tables <- function() {

  # Query
  tables <- jsonlite::fromJSON("https://ws.parlament.ch/odata.svc/") %>%
    as.data.frame() %>%
    dplyr::pull(EntitySets) %>%
    as.character() %>%
    sort()

  return(tables)

}
zumbov2/swissparl documentation built on July 28, 2022, 11:34 a.m.