{"id":13690569,"url":"https://cderv.github.io/opendatarte/","last_synced_at":"2025-05-02T11:31:20.682Z","repository":{"id":78261844,"uuid":"192100803","full_name":"cderv/opendatarte","owner":"cderv","description":"Access https://data.rte-france.com API from R","archived":false,"fork":false,"pushed_at":"2019-06-16T18:22:36.000Z","size":92,"stargazers_count":8,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-22T19:03:37.811Z","etag":null,"topics":["api-client","opendata","r"],"latest_commit_sha":null,"homepage":"https://cderv.github.io/opendatarte/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cderv.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-06-15T16:33:30.000Z","updated_at":"2020-10-22T17:07:33.000Z","dependencies_parsed_at":"2023-03-12T03:00:19.127Z","dependency_job_id":null,"html_url":"https://github.com/cderv/opendatarte","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cderv%2Fopendatarte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cderv%2Fopendatarte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cderv%2Fopendatarte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cderv%2Fopendatarte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cderv","download_url":"https://codeload.github.com/cderv/opendatarte/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252030176,"owners_count":21683301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","opendata","r"],"created_at":"2024-08-02T17:00:22.064Z","updated_at":"2025-05-02T11:31:20.359Z","avatar_url":"https://github.com/cderv.png","language":"R","funding_links":[],"categories":[":package: Packages :package:"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n# opendatarte\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/opendatarte)](https://cran.r-project.org/package=opendatarte)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n\u003c!-- badges: end --\u003e\n\nThe goal of opendatarte is to help connect to https://data.rte-france.com and access data from its different resources API. \n\n**This package is in development.**\n\n* The authentication mechanism is rather stable. It won't change a lot in the future.\n* The functions to call ressources may evolve to have cleaner R API and to be easy to maintain. It may change heavily in the future.\n\n## Installation\n\nThe package is not on CRAN yet. You can installed the development version from [GitHub](https://github.com/) with:\n\n* using `install-github.me` service\n```r\nsource(\"https://install-github.me/cderv/opendatarte\")\n```\n\n* using `remotes`\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"cderv/opendatarte\")\n```\n\n* using `devtools`\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"cderv/opendatarte\")\n```\n\n* using `pak`\n\n```r\npak::pkg_install(\"cderv/opendatarte\")\n```\n\n## How to use\n\n### Create an application and register some API\n\nThis package is useful to connect to your application on https://data.rte-france.com. \nConnect to the website, create an account and add an application. You can follow the help on the website. \n\nOnce 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. \n\n### Configure R client to authenticate\n\n```{r, eval = FALSE}\nlibrary(opendatarte)\n```\n\nThe 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`.\n\nTo configure them you can use `usethis::edit_r_environ()`.\n\n```{r, eval = FALSE}\ndatarte_auth()\n```\n\n\nYou can also provide _client\\_id_ and _secret\\_id_ as argument directly.\n\n```{r, eval = FALSE}\ndatarte_auth(client_id = \"xxxxxxxxxx\", client_secret = \"xxxxxxxxxxxxxx\")\n```\n\nor even, for advanced use, an httr token object directly in the token argument\n```{r, eval = FALSE}\ndatarte_auth(token = \"a-stored-token.rds\")\n```\n\nAll 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.\n\nThis 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.\n\nIf you want to use `httr` directly and not this package for accessing the data, you can \n\n* save the object to reuse it in httr\n```{r, eval = FALSE}\nmy_token \u003c- datarte_auth()\nauth_rte \u003c- httr::config(token = my_token)\n```\n\nYou can put it any calls from `httr` like this\n```r\nhttr::GET(\"https://httpbin.org/get\", auth_rte)\n```\nThe authentication will be handle to access the data\n\n* use the helper provided in this package. It will pass the token to the API correctly \n```{r, eval = FALSE}\ndatarte_auth()\nhttr::GET(\"https://httpbin.org/get\", datarte_token())\n```\n\n### Access data from the API using this package\n\nThere 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.\n\nThey are all built on the same following concepts\n\n* In an interactive session, if several types of data are available for the same ressource, it will ask the one you want to use\n```{r, eval = FALSE}\n# get data from the \nres \u003c- RegistreAPI()\n```\n* You can provide a ressource path directly\n\n```{r, eval = FALSE}\nres \u003c- RegistreAPI(\"ncc_less_100_mw\")\n```\n\n* By default, it will use the sandbox url (see api documentation for details). Use `sandbox = FALSE` if needed.\n```{r, eval = FALSE}\nres \u003c- RegistreAPI(\"ncc_less_100_mw\", sandbox = FALSE)\n```\n\n* It will refresh your token automatically if it has expired. You can prevent that using `refresh = FALSE`\n```{r, eval = FALSE}\nres \u003c- RegistreAPI(\"ncc_less_100_mw\", refresh = FALSE)\n```\n\nThe results are currently of the following structure. It is a list with 3 elements\n\n* `res$content`: The parsed json as a list\n* `res$path`: the ressource path from where are the data\n* `res$response`: The httr response object. Could be useful for advanced use. \n\n### About available resources\n\nAll the ressources are not yet available in this package. The way to expose all the ressource is not clear yet and this could evolved. \n\nAvailable ressource are :\n\n* Unavailability Additional Information \n* Certified Capacities Registry \n\n\n#### Advanced Usage: Getting more resources\n\nAll the function are built upon `call_api` that can be used with any resource path for the api documentation.\n\n```{r, eval = FALSE}\nres \u003c- call_api(\"unavailability_additional_information/v1/sandbox/transmission_network_unavailabilities\")\n```\n\nMain advantage is that it will return the same type of objects are previous functions and know how to use authentication. \n\nYou can also use `httr` directly by using the token `datarte_token()` in the call to the API. \nYou 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\n\n# In the future\n\n* Add a mechanism to add more resources and update them\n* Add mechanism to connect also to https://opendata.reseaux-energies.fr\n* Add functions to get result as tibble and not just list from parsed json.\n\n# Other related package\n\nThere is also the [rte.data](https://github.com/dreamRs/rte.data) that will work to use the data.rte-france.com API\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/cderv.github.io%2Fopendatarte%2F","html_url":"https://awesome.ecosyste.ms/projects/cderv.github.io%2Fopendatarte%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/cderv.github.io%2Fopendatarte%2F/lists"}