The goal of opendatarte is to help connect to https://data.rte-france.com and access data from its different resources API.
This package is in development.
The package is not on CRAN yet. You can installed the development version from GitHub with:
install-github.me
serviceremotes
devtools
pak
This package is useful to connect to your application on https://data.rte-france.com. Connect to the website, create an account and add an application. You can follow the help on the website.
Once your application is created you’ll get a client_id and a secret_id. You will need them to connect to your application form R using this package.
The main fonction is datarte_auth()
. The simplest way to use it is to configure your R session with some environment variable containing your secrets: RTE_API_CLIENT
and RTE_API_SECRET
.
To configure them you can use usethis::edit_r_environ()
.
You can also provide client_id and secret_id as argument directly.
or even, for advanced use, an httr token object directly in the token argument
All this will do the same: It will configure you current R session so that the package opendatarte knows the credentials. You can then use the API using this package without no further authentication step.
This package is also compatible with the cache mechanism from httr. You can set cache = TRUE
so that token is saved to disk and will be reused in future sessions, and not just the current session.
If you want to use httr
directly and not this package for accessing the data, you can
You can put it any calls from httr
like this
The authentication will be handle to access the data
There is some functions included in this package to be use with specific ressources. They aim at easing the use of the API by wrapping endpoints and query parameter.
They are all built on the same following concepts
sandbox = FALSE
if needed.refresh = FALSE
The results are currently of the following structure. It is a list with 3 elements
res$content
: The parsed json as a listres$path
: the ressource path from where are the datares$response
: The httr response object. Could be useful for advanced use.All the ressources are not yet available in this package. The way to expose all the ressource is not clear yet and this could evolved.
Available ressource are :
All the function are built upon call_api
that can be used with any resource path for the api documentation.
res <- call_api("unavailability_additional_information/v1/sandbox/transmission_network_unavailabilities")
Main advantage is that it will return the same type of objects are previous functions and know how to use authentication.
You can also use httr
directly by using the token datarte_token()
in the call to the API. You can also use any other request package, you can get the current access token with get_current_token(TRUE)
to be used with any tool you prefere, according the API documentation