beaumontmeteo/R/getStationPaquet.R
2026-04-11 09:24:56 +01:00

31 lines
606 B
R

getStationPaquet <- function(
id_station,
format = "csv",
headers,
endpoint = paste0(dpPaquetObs, "infrahoraire-6m")
) {
url_with_params <- httr::modify_url(
base,
path = endpoint,
query = list(id_station = id_station, format = format)
)
response <- request_api(
url_with_params = url_with_params,
headers = headers,
code = 200,
retry_limit = 3,
timesleep = 5
)
if (is.null(response)) {
return(NULL)
}
read.csv(
text = httr::content(response, "text", encoding = "UTF-8"),
sep = ";",
header = TRUE,
stringsAsFactors = FALSE
)
}