| Title: | 'Earth Blox' API Client |
|---|---|
| Description: | Client library for the 'Earth Blox' API (<https://api.earthblox.io/>). Provides authentication and endpoints for interacting with 'Earth Blox' geospatial analytics services. Compatible with 'Shiny' applications. |
| Authors: | Neil Mayo [aut, cre], Quosient Ltd. [cph] |
| Maintainer: | Neil Mayo <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-05-17 05:26:41 UTC |
| Source: | https://github.com/cran/ebx |
Base R6 class for authentication methods
auth_tokenThe authentication token
configThe client configuration
new()
Create a new AbstractAuthentication object
AbstractAuthentication$new(config)
configThe client configuration
A new AbstractAuthentication object
has_expired()
Check if the token has expired
AbstractAuthentication$has_expired()
TRUE if expired, FALSE otherwise
refresh()
Refresh the authentication token
AbstractAuthentication$refresh()
self
get_headers()
Get the headers for HTTP requests
AbstractAuthentication$get_headers()
A named character vector of headers
clone()
The objects of this class are cloneable with this method.
AbstractAuthentication$clone(deep = FALSE)
deepWhether to make a deep clone.
Check if a token file exists
auth_token_exists(config, filename)auth_token_exists(config, filename)
config |
The client config |
filename |
The filename to check |
TRUE if the file exists, FALSE otherwise
Low-level authentication function
auth_using(authenticator, config = NULL, name = NULL)auth_using(authenticator, config = NULL, name = NULL)
authenticator |
The authentication object |
config |
The client configuration (optional) |
name |
The client name (optional) |
An EbxClient object
Authenticate using saved OAuth credentials from disk
auth_using_creds(filename = API_SECRETS_FILE, name = NULL, config = NULL)auth_using_creds(filename = API_SECRETS_FILE, name = NULL, config = NULL)
filename |
The credentials filename (optional) |
name |
The client name (optional) |
config |
The client configuration (optional) |
An EbxClient object
Authenticate using the EBX_API_TOKEN environment variable
auth_using_env(name = NULL, config = NULL)auth_using_env(name = NULL, config = NULL)
name |
The client name (optional) |
config |
The client configuration (optional) |
An EbxClient object
Authenticate using OAuth client credentials
auth_using_oauth( client_id = NULL, client_secret = NULL, name = NULL, config = NULL )auth_using_oauth( client_id = NULL, client_secret = NULL, name = NULL, config = NULL )
client_id |
The client ID (optional, can be from env) |
client_secret |
The client secret (optional, can be from env) |
name |
The client name (optional) |
config |
The client configuration (optional) |
An EbxClient object
R6 class for authentication tokens
tokenThe access token
expiresThe expiration datetime
new()
Create a new AuthToken object
AuthToken$new(token = NULL, expires = NULL)
tokenThe access token
expiresThe expiration datetime (as POSIXct or string)
A new AuthToken object
save()
Save the token to disk
AuthToken$save(config, filename)
configThe client config
filenameThe filename to save to
self (invisible)
to_list()
Convert AuthToken to a plain list
AuthToken$to_list(include_token = FALSE)
include_tokenWhether to include the actual token (default: FALSE for security)
A list containing auth token fields
to_json()
Convert AuthToken to JSON string
AuthToken$to_json(pretty = TRUE, include_token = FALSE, ...)
prettyWhether to pretty-print the JSON (default: TRUE)
include_tokenWhether to include the actual token (default: FALSE for security)
...Additional arguments passed to jsonlite::toJSON
A JSON string representation of the auth token
clone()
The objects of this class are cloneable with this method.
AuthToken$clone(deep = FALSE)
deepWhether to make a deep clone.
Authentication using username and password
ebx::AbstractAuthentication -> BasicAuth
emailThe email address
passwordThe password
new()
Create a new BasicAuth object
BasicAuth$new(config, email, password)
configThe client configuration
emailThe email address
passwordThe password
A new BasicAuth object
has_expired()
Check if token has expired (always FALSE for basic auth)
BasicAuth$has_expired()
FALSE
refresh()
Refresh (not supported for basic auth)
BasicAuth$refresh()
self
get_headers()
Get the headers for HTTP requests
BasicAuth$get_headers()
A named character vector of headers
clone()
The objects of this class are cloneable with this method.
BasicAuth$clone(deep = FALSE)
deepWhether to make a deep clone.
R6 class for Earth Blox API client configuration
base_urlThe base URL for the API
api_prefixThe version prefix for the API
oauth_pathThe path for the OAuth flow
persistence_driverThe persistence driver for storing credentials
new()
Create a new ClientConfig object
ClientConfig$new(persistence_driver = NULL)
persistence_driverOptional persistence driver to use for storing
credentials. If NULL (default), a LocalFilePersistence writing
to a sub-directory of tempdir() is used. Pass a
MemoryPersistence instance for hosted environments such as
shinyapps.io where file persistence might be undesirable.
A new ClientConfig object
get_api_base_url()
Get the full API base URL including version prefix
ClientConfig$get_api_base_url()
The full API base URL
get_oauth_url()
Get the OAuth URL
ClientConfig$get_oauth_url()
The OAuth URL
get_persistence_driver()
Get the persistence driver
ClientConfig$get_persistence_driver()
The persistence driver
set_persistence_driver()
Set the persistence driver
ClientConfig$set_persistence_driver(driver)
driverA persistence driver object (e.g. LocalFilePersistence
or MemoryPersistence)
self (invisible)
clone()
The objects of this class are cloneable with this method.
ClientConfig$clone(deep = FALSE)
deepWhether to make a deep clone.
Register a new OAuth client with the API
create_oauth_client(email, password, name, description = "", scopes = c())create_oauth_client(email, password, name, description = "", scopes = c())
email |
The email address of the user |
password |
The password of the user |
name |
The name for the new client |
description |
The description for the new client (optional) |
scopes |
The scopes for the new client (optional) |
An OAuthClient object
Create a new run using the specified project
This function supports two modes: 1. Pass a complete project_spec (list or Project object) with variables 2. Pass individual parameters (project_id + optional substitutions)
create_run( project_spec = NULL, project_id = NULL, start_date = NULL, end_date = NULL, study_area = NULL, include_geometry = FALSE, generate_thumbnails = FALSE )create_run( project_spec = NULL, project_id = NULL, start_date = NULL, end_date = NULL, study_area = NULL, include_geometry = FALSE, generate_thumbnails = FALSE )
project_spec |
Optional complete project specification (list or Project object). If provided, this takes precedence over individual parameters. |
project_id |
The project ID (ignored if project_spec provided) |
start_date |
Optional start date (datetime or string) - uses deprecated substitutions API |
end_date |
Optional end date (datetime or string) - uses deprecated substitutions API |
study_area |
Optional study area - uses deprecated substitutions API |
include_geometry |
Whether to include geometry in output (default: FALSE) |
generate_thumbnails |
Whether to generate thumbnails for every layer (default: FALSE) |
The run ID as a string
## Not run: # Method 1: Using project_spec with variables (recommended) spec <- Project$new( id = "project123", variables = list( list(key = "var_1", type = "area", value = geojson_data) ) ) run_id <- create_run(project_spec = spec) # Method 2: Using individual parameters with substitutions (deprecated) run_id <- create_run( project_id = "project123", start_date = "2024-01-01", end_date = "2024-12-31", study_area = geojson_data ) ## End(Not run)## Not run: # Method 1: Using project_spec with variables (recommended) spec <- Project$new( id = "project123", variables = list( list(key = "var_1", type = "area", value = geojson_data) ) ) run_id <- create_run(project_spec = spec) # Method 2: Using individual parameters with substitutions (deprecated) run_id <- create_run( project_id = "project123", start_date = "2024-01-01", end_date = "2024-12-31", study_area = geojson_data ) ## End(Not run)
R6 class for Earth Blox API client
nameThe name of the client
configThe client configuration
authenticatorThe authentication method
new()
Create a new EbxClient object
EbxClient$new(authenticator = NULL, config = NULL, name = NULL)
authenticatorThe authentication method
configThe client configuration (optional)
nameThe client name (optional)
A new EbxClient object
get_headers()
Get headers for HTTP requests
EbxClient$get_headers()
A named character vector of headers
parse_response()
Parse response body based on Content-Type header
EbxClient$parse_response(response)
responseThe httr2 response object
The parsed response data
get()
Make a GET request to the API
EbxClient$get(url, query_params = NULL, headers = NULL, timeout = NULL)
urlThe endpoint URL
query_paramsQuery parameters (optional)
headersAdditional headers (optional)
timeoutRequest timeout in seconds (optional)
The parsed response data
post()
Make a POST request to the API
EbxClient$post(url, payload = NULL, headers = NULL, timeout = NULL)
urlThe endpoint URL
payloadThe request payload (optional)
headersAdditional headers (optional)
timeoutRequest timeout in seconds (optional)
The parsed response data
clone()
The objects of this class are cloneable with this method.
EbxClient$clone(deep = FALSE)
deepWhether to make a deep clone.
Authentication using environment variable token
ebx::AbstractAuthentication -> EnvAuthentication
new()
Create a new EnvAuthentication object
EnvAuthentication$new(config)
configThe client configuration
A new EnvAuthentication object
has_expired()
Check if token has expired (always FALSE for env auth)
EnvAuthentication$has_expired()
FALSE
refresh()
Refresh the token from environment
EnvAuthentication$refresh()
self
get_headers()
Get the headers for HTTP requests
EnvAuthentication$get_headers()
A named character vector of headers
clone()
The objects of this class are cloneable with this method.
EnvAuthentication$clone(deep = FALSE)
deepWhether to make a deep clone.
Follow a run's progress (polling)
follow_run(run_id, interval = 5, max_attempts = 60)follow_run(run_id, interval = 5, max_attempts = 60)
run_id |
The run ID |
interval |
Polling interval in seconds (default: 5) |
max_attempts |
Maximum number of polling attempts (default: 60) |
The final Run object
Get charts from a run
get_charts(run_id, filter = NULL)get_charts(run_id, filter = NULL)
run_id |
The run ID |
filter |
Optional filter to apply to chart titles |
A list of chart data
Get an existing client or the current default client
get_client(name = NULL)get_client(name = NULL)
name |
The client name (optional) |
An EbxClient object
Get layers from a run
get_layers(run_id, filter = NULL)get_layers(run_id, filter = NULL)
run_id |
The run ID |
filter |
Optional filter to apply to layer titles |
A list of layer data
Get a specific project by ID
get_project(project_id)get_project(project_id)
project_id |
The project ID |
A Project object
Get a specific run by ID
get_run(run_id)get_run(run_id)
run_id |
The run ID |
A Run object
Get the status of a specific run
get_run_status(run_id)get_run_status(run_id)
run_id |
The run ID |
The run status as a string
Get tables from a run
get_tables(run_id, filter = NULL)get_tables(run_id, filter = NULL)
run_id |
The run ID |
filter |
Optional filter to apply to table titles |
A list of table data
List all available projects
list_projects()list_projects()
A list of Project objects
List runs with optional limit
list_runs(limit = 10)list_runs(limit = 10)
limit |
The maximum number of runs to return (default: 10) |
A list of Run objects
Load an auth token from a saved file
load_auth_token(config, filename)load_auth_token(config, filename)
config |
The client config |
filename |
The filename to load from |
An AuthToken object
Load an OAuth client from a saved file
load_oauth_client(config = NULL, filename = API_SECRETS_FILE)load_oauth_client(config = NULL, filename = API_SECRETS_FILE)
config |
The client config (optional) |
filename |
The filename to load from (optional) |
An OAuthClient object
R6 class for persisting credentials to local filesystem
pathThe directory path for storing files
new()
Create a new LocalFilePersistence object
LocalFilePersistence$new(path)
pathThe directory path for storing files. Must be supplied explicitly; no default is provided to comply with CRAN policy.
A new LocalFilePersistence object
save()
Save data to a file
LocalFilePersistence$save(filename, data)
filenameThe name of the file
dataThe data to save (will be converted to JSON)
NULL (invisible)
load()
Load data from a file
LocalFilePersistence$load(filename)
filenameThe name of the file
The loaded data as a list
exists()
Check if a file exists
LocalFilePersistence$exists(filename)
filenameThe name of the file
TRUE if the file exists, FALSE otherwise
clone()
The objects of this class are cloneable with this method.
LocalFilePersistence$clone(deep = FALSE)
deepWhether to make a deep clone.
R6 class for persisting credentials in memory (e.g. on hosted environments such as shinyapps.io where the local filesystem is not writable). Data is lost when the R session ends.
storeNamed list used as an in-memory store
new()
Create a new MemoryPersistence object
MemoryPersistence$new()
A new MemoryPersistence object
save()
Save data to memory
MemoryPersistence$save(filename, data)
filenameThe key to store data under
dataThe data to save (stored in its native R form)
NULL (invisible)
load()
Load data from memory
MemoryPersistence$load(filename)
filenameThe key to load data from
The stored data as a list
exists()
Check if a key exists in memory
MemoryPersistence$exists(filename)
filenameThe key to check
TRUE if the key exists, FALSE otherwise
clone()
The objects of this class are cloneable with this method.
MemoryPersistence$clone(deep = FALSE)
deepWhether to make a deep clone.
Check if a credentials file exists
oauth_credentials_exist(config = NULL, filename = API_SECRETS_FILE)oauth_credentials_exist(config = NULL, filename = API_SECRETS_FILE)
config |
The client config (optional) |
filename |
The filename to check (optional) |
TRUE if the file exists, FALSE otherwise
Authentication using OAuth client credentials
ebx::AbstractAuthentication -> OAuthAuthentication
client_idThe client ID
client_secretThe client secret
new()
Create a new OAuthAuthentication object
OAuthAuthentication$new(config, client_id = NULL, client_secret = NULL)
configThe client configuration
client_idThe client ID
client_secretThe client secret
A new OAuthAuthentication object
get_token_filename()
Get the token filename
OAuthAuthentication$get_token_filename()
The filename for storing this client's token
load_saved_credentials()
Load saved credentials from disk
OAuthAuthentication$load_saved_credentials()
self
save_credentials()
Save credentials to disk
OAuthAuthentication$save_credentials()
self
refresh()
Refresh the OAuth token
OAuthAuthentication$refresh()
self
get_headers()
Get the headers for HTTP requests
OAuthAuthentication$get_headers()
A named character vector of headers
clone()
The objects of this class are cloneable with this method.
OAuthAuthentication$clone(deep = FALSE)
deepWhether to make a deep clone.
R6 class for OAuth client credentials
nameThe name of the client
descriptionThe description of the client
client_idThe client ID
client_secretThe client secret
enabledWhether the client is enabled
new()
Create a new OAuthClient object
OAuthClient$new( name = NULL, description = NULL, client_id = NULL, client_secret = NULL, enabled = NULL )
nameThe name of the client
descriptionThe description of the client
client_idThe client ID
client_secretThe client secret
enabledWhether the client is enabled
A new OAuthClient object
save()
Save the OAuth client to disk
OAuthClient$save(config = NULL, filename = API_SECRETS_FILE)
configThe client config (optional)
filenameThe filename to save to (optional)
self (invisible)
to_list()
Convert OAuthClient to a plain list
OAuthClient$to_list(include_secret = FALSE)
include_secretWhether to include client_secret (default: FALSE for security)
A list containing OAuth client fields
to_json()
Convert OAuthClient to JSON string
OAuthClient$to_json(pretty = TRUE, include_secret = FALSE, ...)
prettyWhether to pretty-print the JSON (default: TRUE)
include_secretWhether to include client_secret (default: FALSE for security)
...Additional arguments passed to jsonlite::toJSON
A JSON string representation of the OAuth client
clone()
The objects of this class are cloneable with this method.
OAuthClient$clone(deep = FALSE)
deepWhether to make a deep clone.
R6 class representing a project
idThe project ID
nameThe project name (mapped from API 'title' field)
descriptionThe project description
versionThe project version
api_versionThe API version
api_accessWhether API access is enabled
variablesList of project variables
exec_parametersExecution parameters configuration
new()
Create a new Project object
Project$new( id = NULL, name = NULL, description = NULL, version = NULL, api_version = NULL, api_access = NULL, variables = NULL, exec_parameters = NULL, title = NULL, ... )
idThe project ID
nameThe project name
descriptionThe project description
versionThe project version
api_versionThe API version
api_accessWhether API access is enabled
variablesList of project variables
exec_parametersExecution parameters
titleAlternative name for 'name' field (API compatibility)
...Additional fields (ignored)
A new Project object
print()
Print method for Project
Project$print(...)
...Additional arguments (ignored)
to_list()
Convert Project to a plain list
Project$to_list()
A list containing all project fields
to_json()
Convert Project to JSON string
Project$to_json(pretty = TRUE, ...)
prettyWhether to pretty-print the JSON (default: TRUE)
...Additional arguments passed to jsonlite::toJSON
A JSON string representation of the project
clone()
The objects of this class are cloneable with this method.
Project$clone(deep = FALSE)
deepWhether to make a deep clone.
R6 class representing a run
idThe run ID
project_idThe associated project ID
statusThe run status
started_atThe run start timestamp
completed_atThe run completion timestamp
exec_parametersThe execution parameters
layersThe layers associated with the run
outputsThe outputs (charts/tables) associated with the run
nameThe run name (optional)
new()
Create a new Run object
Run$new( id = NULL, project_id = NULL, status = NULL, started_at = NULL, completed_at = NULL, exec_parameters = NULL, layers = NULL, outputs = NULL, name = NULL, ... )
idThe run ID
project_idThe project ID
statusThe run status
started_atThe run start timestamp
completed_atThe run completion timestamp
exec_parametersThe execution parameters
layersThe layers list
outputsThe outputs list
nameThe run name (optional)
...Additional fields (ignored)
A new Run object
print()
Print method for Run
Run$print(...)
...Additional arguments (ignored)
to_list()
Convert Run to a plain list
Run$to_list()
A list containing all run fields
to_json()
Convert Run to JSON string
Run$to_json(pretty = TRUE, ...)
prettyWhether to pretty-print the JSON (default: TRUE)
...Additional arguments passed to jsonlite::toJSON
A JSON string representation of the run
clone()
The objects of this class are cloneable with this method.
Run$clone(deep = FALSE)
deepWhether to make a deep clone.
R6 class for Earth Blox API client configuration for service endpoints
ebx::ClientConfig -> ServiceClientConfig
new()
Create a new ServiceClientConfig object
ServiceClientConfig$new(persistence_driver = NULL)
persistence_driverOptional persistence driver (see
ClientConfig).
A new ServiceClientConfig object
clone()
The objects of this class are cloneable with this method.
ServiceClientConfig$clone(deep = FALSE)
deepWhether to make a deep clone.