I'm new to httr and jsonlite and API calls in general. I'm trying to obtain CO2 data from here: https://docs.co2signal.com/#introduction
I'm receiving the "No API key found in headers or querystring" message. I might be doing something silly. I note that the API documentation mentions that:
"CO2 Signal expects the API key to be included as a header in all requests to the server" I'm not sure if this means I should not use the authenticate function.
Code:
install.packages("httr")
install.packages("jsonlite")
#Require the package so you can use it
require("httr")
require("jsonlite")
auth_token <- "xxxxx" # I'm using my proper API key here
password <- ""
url <- "https://api.co2signal.com/v1/latest"
country_code <- "DE"
# The below may not be the correct format
# de_call <- paste(url, "?","countryCode","=", country_code, "%20&", "auth-token=", auth_token, sep="")
de_call <- paste(url, "?","countryCode","=", country_code, sep="")
de_call
get_de_co2 <- GET(de_call, authenticate(auth_token, password, type = "basic"))
get_co2s_text <- content(get_de_co2, "text")
get_co2s_text