Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

API key in HTTP header

$
0
0

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") 


Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>