Skip to content
format_request.R 1.39 KiB
Newer Older
library(httr)
library(jsonlite)
library(rsdmx)
library(hash)


sdmx_request <- function(url) {
  as.data.frame(readSDMX(myUrl))
}

json_request <- function(url) {
  fromJSON(rawToChar(GET(url)$content))
}

csv_request <- function(url) {
  read.csv(url)
}

REQUEST_FUNCTION_MAPPING <- hash(
  "SDMX" = sdmx_request,
  "JSON" = json_request,
  "CSV" = csv_request
json <- fromJSON(rawToChar(GET("https://www.i14y.admin.ch/api/ContentConfigurations")$content))

names(json)
json$identifier

res <- GET("https://www.i14y.admin.ch/api/ContentConfigurations/HCL_CH_ISCO_19_PROF")
cc <- fromJSON(rawToChar(res$content))

res <- GET("https://www.i14y.admin.ch/api/Nomenclatures/Childnodes/HCL_CH_ISCO_19_PROF/fr/.?additionalProp1=string")
ncn <- fromJSON(rawToChar(res$content))


data1 <- read.csv("https://www.i14y.admin.ch/api/Nomenclatures/HCL_CH_ISCO_19_PROF/levelexport/CSV?level=1&annotations=true&additionalProp2=string&language=fr")
h[['csv']]("https://www.i14y.admin.ch/api/Nomenclatures/HCL_CH_ISCO_19_PROF/levelexport/CSV?level=1&annotations=true&additionalProp2=string&language=fr")

data2 <- read.csv("https://www.i14y.admin.ch/api/Nomenclatures/HCL_CH_ISCO_19_PROF/multiplelevels/CSV?language=fr&levelFrom=1&levelTo=4&annotations=true&additionalProp1=string")

myUrl <- "https://www.i14y.admin.ch/api/CodeLists/CL_NOGA_SECTION/exports/SDMX-ML/2.1?annotations=true"
dataset <- as.data.frame(readSDMX(myUrl))