| Title: | opendatarte |
|---|---|
| Description: | This package is R Client to RTE API of data.rte-france.com. It contains tools and functions to authenticate to the API and retrieves the data. |
| Authors: | Christophe Dervieux [aut, cre] |
| Maintainer: | Christophe Dervieux <[email protected]> |
| License: | GPL-3 |
| Version: | 0.0.0.9000 |
| Built: | 2026-06-10 16:04:09 UTC |
| Source: | https://github.com/cderv/opendatarte |
This function is the base one used in each of the different API functions. It is ressource generic and could be adapted to call the available ressource on the data RTE portal.
call_api(ressource_path, refresh = TRUE, verbose = FALSE)call_api(ressource_path, refresh = TRUE, verbose = FALSE)
ressource_path |
string. Endpoint of the ressource as describe in data rte API documentation available on data.rte-france.com (part of the url after /open_api/) |
refresh |
logical. force to |
verbose |
logical. |
an rte_api object as a list with
content: the parsed json resulting from the API call
path: the ressource called by the API request
response: the raw response from the API call.
It is the main fonction to use for accessing RTE Data API. It will request an access token for the current session if none currently exists and be valid.
datarte_auth(token = NULL, client_id = NULL, client_secret = NULL, cache = FALSE)datarte_auth(token = NULL, client_id = NULL, client_secret = NULL, cache = FALSE)
token |
optional argument. it exists to supply manually a token.
|
client_id |
character. the client id for the app. default |
client_secret |
character. the client secret for the app. default
|
cache |
logical or a string. |
You can configure your R session to use always some client and secret by
setting RTE_API_CLIENT and RTE_API_SECRET environment variable
with base::Sys.setenv()
invisibly the Token which is saved for the current session,
and will be used when needed.
This function is inspired by googlesheet package and its Oauth2 system.
## Not run: client_id <- "cliend_id" client_secret <- "client_secret" datarte_auth(client_id = client_id, client_secret = client_secret, cache = F) ## End(Not run)## Not run: client_id <- "cliend_id" client_secret <- "client_secret" datarte_auth(client_id = client_id, client_secret = client_secret, cache = F) ## End(Not run)
If token is not already available in the current session, this function will stop execution. An active token for the current session must be requested before any other task.
datarte_token(verbose = FALSE)datarte_token(verbose = FALSE)
verbose |
Set to |
Use get_current_token() to check for valid token.
a request object (an S3 class provided by httr). It is the token prepared for
use with httr configuration system. see httr::config().
## Not run: # use in httr fonction like GET for authentification as config for httr datarte_auth(client_id, client_secret) httr::GET("https://httpbin.org/get", datarte_token()) ## End(Not run)## Not run: # use in httr fonction like GET for authentification as config for httr datarte_auth(client_id, client_secret) httr::GET("https://httpbin.org/get", datarte_token()) ## End(Not run)
Get current active token
get_current_token(only_access_token = F)get_current_token(only_access_token = F)
only_access_token |
logical. Default to |
If TRUE, just the token string is returned not the whole token object.
If no token is available, for the current session, it returns NULL
get_current_token() # Returns NULL or token object credentials get_current_token(TRUE) # Returns NULL or access token string only.get_current_token() # Returns NULL or token object credentials get_current_token(TRUE) # Returns NULL or access token string only.
Retrieve data from the capacity market public registry
RegistreAPI(ressource = NULL, sandbox = T, refresh = T)RegistreAPI(ressource = NULL, sandbox = T, refresh = T)
ressource |
name of the ressource to call in the API. Choices are describe in API documentation on the website http://www.data.rte-france.com |
sandbox |
logical. |
refresh |
lofical. |
Other API-calls: unavailabilityAPI