#' fonction pour telecharger un ficher de api sncf
#'
#' @param dataset nom de la dataset
#'
#' @return a \code{data.frame}
#' @export
#' @importFrom crul HttpClient
#' @importFrom jsonlite fromJSON toJSON
#'
#' @examples
#' \dontrun{
#' get_sncf("ponctualite-mensuelle-transilien")
#' get_sncf ("tarif-abonnement-ile-de-france")
#' }
get_sncf <- function(dataset = "ponctualite-mensuelle-transilien") {
cli <- HttpClient$new (
url = "https://ressources.data.sncf.com/api/records/1.0/search/"
)
res <- cli$get(query = list(rows = -1, dataset = dataset))
res$raise_for_status()
txt <- res$parse("UTF-8")
json <- fromJSON(txt)
return(json$records)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.