Trying to access AirQuality API, very new to this and do not see simple R tutorials.
Got my username and password.
And I am interested to get LA data as a sample
api.airvisual.com/v2/city?city=Los Angeles&state=California&country=USA&key={{KEY}}
My credentials
username <- "My new free api key" (that is how they give it)
password <- "KEY"
Then I try to use some code from tutorials
library(httr)
library(jsonlite)
url <- "api.airvisual.com/v2/city?city=Los Angeles&state=California&country=USA&key={{KEY}}"
endpoint <- "city"
some_data <- GET(url, endpoint)
It gives me an error
Error in if (is_http) { : argument is of length zero
Their parameters are
Parameters
city: city's English name, can be found using the respective listing endpoint.
state: state's English name, can be found using the respective listing endpoint.
country: country's English name, can be found using the respective listing endpoint.
I am sure it is something super simple, but I never did it before, so I stumbled. Please advise.
UPD.
When I use
url <- "api.airvisual.com/v2/city?city=Los%20Angeles&state=California&country=USA&key={{KEY}}"
with %20 instead of space, it gives me an error
Error in UseMethod("as.request") : no applicable method for 'as.request' applied to an object of class "character"