I want to get some data from Polish Central Statistical Office using API query. Due to limitation I can't send more than 100 queries per 15 min. However, if I provide specific API key I would be able to download much more data. With accordance to their tutorial API key should be provided in the request as an HTTP header (tutorial p. 3). Example:
GET https://bdl.stat.gov.pl/api/v1/data/by-variable/3643?format=xml&year=2000&year=2010 HTTP/1.1
Host: hostname
X-ClientId: 1A6B2AB1-0DF0-4DAC-74A3-07D7C07FC3BE
I tried to use follow code but it does not work:
token <- "my_key" # my secret key
#
httr::GET("https://bdl.stat.gov.pl/api/v1/data/by-variable/3643?format=xml&year=2000&year=2010",
add_headers(Authorization=token)) %>%
content("text", encoding = "UTF-8") %>%
fromJSON(flatten = T) %>%
extract2("results")