Package 'opendatarte'

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

Help Index


Generic function to call RTE Data API

Description

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.

Usage

call_api(ressource_path, refresh = TRUE, verbose = FALSE)

Arguments

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 FALSE to prevent refresh

verbose

logical.

Value

an rte_api object as a list with

  1. content: the parsed json resulting from the API call

  2. path: the ressource called by the API request

  3. response: the raw response from the API call.


Obtain credentials for RTE Data API

Description

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.

Usage

datarte_auth(token = NULL, client_id = NULL, client_secret = NULL,
  cache = FALSE)

Arguments

token

optional argument. it exists to supply manually a token.

  • if NULL (the default), the current token for the active session will be used.

  • if a character, it assumes to be the path to a rds file containing a valid Token2.0 object from httr

  • a Token2.0 object directly

client_id

character. the client id for the app. default NULL - will use the RTE_API_CLIENT environment variable.

client_secret

character. the client secret for the app. default NULL

  • will use the RTE_API_SECRET environment variable.

cache

logical or a string. TRUE to cache the access token into a file. A string means use the specified file. See httr::oauth2.0_token() for details.

Details

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()

Value

invisibly the Token which is saved for the current session, and will be used when needed.

References

This function is inspired by googlesheet package and its Oauth2 system.

Examples

## 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)

Produces token for data.rte-france.com

Description

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.

Usage

datarte_token(verbose = FALSE)

Arguments

verbose

Set to TRUE to print information.

Details

Use get_current_token() to check for valid token.

Value

a request object (an S3 class provided by httr). It is the token prepared for use with httr configuration system. see httr::config().

Examples

## 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

Description

Get current active token

Usage

get_current_token(only_access_token = F)

Arguments

only_access_token

logical. Default to FALSE

Value

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

Examples

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

Description

Retrieve data from the capacity market public registry

Usage

RegistreAPI(ressource = NULL, sandbox = T, refresh = T)

Arguments

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. TRUE to call the sandbox URL for testing

refresh

lofical. TRUE to allow refresh.

See Also

Other API-calls: unavailabilityAPI


Retrieve data from the production API

Description

Retrieve data from the production API

Usage

unavailabilityAPI(ressource = NULL, sandbox = TRUE, refresh = TRUE)

Arguments

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. TRUE to call the sandbox URL for testing

refresh

lofical. TRUE to allow refresh.

See Also

Other API-calls: RegistreAPI