I'm trying to access the aletheia api using httr in R.
currently my code looks like the the example below. But this return an respons stating that I have not supplied my key in the request. Where am I going wrong?
key <- "my_key"
base_url <- "https://api.aletheiaapi.com/LatestTransactions"
header <- c("key" = key)
testing_insiders <- GET(base_url, add_headers(header), query = list(
issuer = "1800"
))
testing_insiders
CodePudding user response:
You can actually provide the key either as a header named "key" or as a query term. Both of these work for me:
url <- "https://api.aletheiaapi.com/StockData?symbol=msft"
header <- c("key" = "MY_KEY")
r <- GET(url,
add_headers(header))
content(r)
url <- "https://api.aletheiaapi.com/StockData?symbol=msft&key=MY_KEY"
r <- GET(url)
content(r)
If I used an invalid key then I get the message you saw. I suspect there is a problem with your key (not copied correctly, expired, too many requests, or something else.)