if (FALSE) {
# Initialize a new client
try(
client <- Client$new()
)
# Or use environment variable for token
Sys.setenv(HAKAI_API_TOKEN = "token_type=Bearer&access_token=TOKEN")
try(
client <- Client$new()
)
# Follow authorization prompts to log in
# Retrieve some data. See for options.
try(
projects_2020 <- client$get("/aco/views/projects?project_year=2020&fields=project_name")
)
try(
print(projects_2020)
)
# # A tibble: 20 x 1
# project_name
#
# 1 Fountain FN
# 2 Haig Glacier
# 3 Fraser River - Chimney Creek West William Canyon
# 4 Cruickshank WS
# ...
}
## ------------------------------------------------
## Method `Client$new`
## ------------------------------------------------
try(
client <- Client$new()
)
# Using environment variable
Sys.setenv(HAKAI_API_TOKEN = "token_type=Bearer&access_token=TOKEN")
try(
client <- Client$new()
)
# Using custom credentials file
try(
client <- Client$new(credentials_file = "/path/to/creds")
)
## ------------------------------------------------
## Method `Client$get`
## ------------------------------------------------
try(client$get("/aco/views/projects"))
try(client$get("https://hecate.hakai.org/api/aco/views/projects"))
## ------------------------------------------------
## Method `Client$remove_credentials`
## ------------------------------------------------
try(
client$remove_credentials()
)
Run the code above in your browser using DataLab