#' Retrieve list of available stations from GIOS API
#'
#' @examples
#' \dontrun{
#' stations <- get_stations()
#' subset(stations, city.name == "Wrocław")
#' }
#'
#' @export
get_stations <- function(){
request <- GET(url = "http://api.gios.gov.pl/pjp-api/rest/station/findAll")
if(status_code(request) != 200){
stop(paste("Problem z API:\n", http_status(request)$message))
}
stations <- content(request)
stations <- lapply(stations, unlist)
col_names <- names(stations[[1]])
stations <- do.call(rbind.data.frame, stations)
colnames(stations) <- col_names
return(stations)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.