Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Open a [feature request](https://github.com/krose/entsoeapi/issues/new?template=
covr::package_coverage()
```

6. Open the pull request against `master` and describe what changed and why.
6. Open the pull request against `main` and describe what changed and why.

### Conventions

Expand Down
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: entsoeapi
Type: Package
Title: Client for the 'ENTSO-E' Transparency Platform API
Version: 1.0.0
Version: 1.1.0
Authors@R: c(person("Kenneth", "Rose", role=c("aut", "cph"), email="kennethrose82@gmail.com"),
person("Sándor", "Budai", role=c("aut", "cre", "cph"), email="sbudai.ga@gmail.com"))
Description: Provides a standardized R client for the 'ENTSO-E' (European Network of
Expand Down Expand Up @@ -37,9 +37,12 @@ Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0),
curl,
tibble,
tidyselect,
ggplot2
ggplot2,
kableExtra,
scales
VignetteBuilder: knitr
Config/testthat/edition: 3
Collate:
Expand Down
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(accounting_point_eic)
export(activated_balancing_prices)
export(aggregated_balancing_energy_bids)
export(aggregated_bids)
export(all_allocated_eic)
export(all_approved_eic)
export(allocated_transfer_capacities_3rd_countries)
export(allocation_of_cross_zonal_balancing_cap)
Expand Down Expand Up @@ -40,6 +41,7 @@ export(gen_per_gen_unit)
export(gen_per_prod_type)
export(gen_storage_mean_filling_rate)
export(gen_wind_solar_forecasts)
export(get_news)
export(hvdc_link_constrains)
export(imbalance_prices)
export(imbalance_volumes)
Expand Down Expand Up @@ -87,13 +89,16 @@ importFrom(checkmate,assert_integerish)
importFrom(checkmate,assert_string)
importFrom(cli,cli_abort)
importFrom(cli,cli_alert)
importFrom(cli,cli_alert_danger)
importFrom(cli,cli_alert_info)
importFrom(cli,cli_alert_success)
importFrom(cli,cli_alert_warning)
importFrom(cli,cli_h1)
importFrom(cli,cli_h2)
importFrom(cli,cli_progress_bar)
importFrom(cli,cli_progress_done)
importFrom(cli,cli_progress_update)
importFrom(cli,cli_text)
importFrom(cli,cli_warn)
importFrom(dplyr,across)
importFrom(dplyr,all_of)
Expand All @@ -116,6 +121,7 @@ importFrom(dplyr,rename)
importFrom(dplyr,rename_with)
importFrom(dplyr,select)
importFrom(dplyr,ungroup)
importFrom(httr2,req_headers)
importFrom(httr2,req_method)
importFrom(httr2,req_perform)
importFrom(httr2,req_progress)
Expand All @@ -138,6 +144,7 @@ importFrom(lubridate,parse_date_time)
importFrom(lubridate,year)
importFrom(lubridate,ymd)
importFrom(snakecase,to_snake_case)
importFrom(stats,runif)
importFrom(stats,setNames)
importFrom(stringr,str_c)
importFrom(stringr,str_detect)
Expand All @@ -157,9 +164,12 @@ importFrom(utils,read.table)
importFrom(utils,unzip)
importFrom(xml2,as_list)
importFrom(xml2,as_xml_document)
importFrom(xml2,read_html)
importFrom(xml2,read_xml)
importFrom(xml2,xml_children)
importFrom(xml2,xml_contents)
importFrom(xml2,xml_find_all)
importFrom(xml2,xml_find_first)
importFrom(xml2,xml_length)
importFrom(xml2,xml_name)
importFrom(xml2,xml_text)
Expand Down
18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# entsoeapi v1.1.0 (2026-03-31)

## New functionality

- 4 new vignettes (Generation Mix Analysis, Getting Started with entsoeapi, Time Series Restructuring Explained, Working with EIC Codes) have been introduced.
- The `all_allocated_eic()` function has been exported.
- The `get_news()` function has been introduced.
- The ENTSO-E API is known for returning 503 (Service Unavailable) response when it's under heavy load or when a client sends too many requests. Hence we have built-in an automated backoff-and-retry mechanism.

## Changes

- Typos fixed in the documentations.
- The package `DESCRIPTION` document slightly adjusted.

## Miscellaneous

- An orphaned, not exported function and its related unit tests have been removed.

# entsoeapi v1.0.0 (2026-03-25)

## New functionality
Expand Down
1 change: 1 addition & 0 deletions R/constants.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.pd_domain <- "eepublicdownloads.blob.core.windows.net"
.pd_alloc_eic <- "cio-lio/xml/allocated-eic-codes.xml"
.pd_csv_eic <- "/cio-lio/csv/"
.feed_url <- "https://external-api.tp.entsoe.eu/news/feed"
possible_eic_chars <- stats::setNames(
object = 0L:36L,
nm = c(as.character(0:9), LETTERS, "-")
Expand Down
134 changes: 114 additions & 20 deletions R/en_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#' @param cache_key Character scalar. The cache key
#' (e.g. `"party_eic_df_key"`).
#'
#' @return A tibble extracted from the source csv.
#'
#' @noRd
fetch_eic_csv <- function(csv_file, cache_key) {
cache_get_or_compute( # nolint: object_usage_linter
Expand Down Expand Up @@ -34,7 +36,7 @@ fetch_eic_csv <- function(csv_file, cache_key) {
#'
#' @export
#'
#' @examplesIf there_is_provider() && nchar(Sys.getenv("ENTSOE_PAT")) > 0L
#' @examplesIf there_is_provider()
#' eic_party <- entsoeapi::party_eic()
#'
#' dplyr::glimpse(eic_party)
Expand Down Expand Up @@ -64,7 +66,7 @@ party_eic <- function() {
#'
#' @export
#'
#' @examplesIf there_is_provider() && nchar(Sys.getenv("ENTSOE_PAT")) > 0L
#' @examplesIf there_is_provider()
#' eic_area <- entsoeapi::area_eic()
#'
#' dplyr::glimpse(eic_area)
Expand Down Expand Up @@ -96,7 +98,7 @@ area_eic <- function() {
#'
#' @export
#'
#' @examplesIf there_is_provider() && nchar(Sys.getenv("ENTSOE_PAT")) > 0L
#' @examplesIf there_is_provider()
#' eic_accounting_point <- entsoeapi::accounting_point_eic()
#'
#' dplyr::glimpse(eic_accounting_point)
Expand Down Expand Up @@ -128,7 +130,7 @@ accounting_point_eic <- function() {
#'
#' @export
#'
#' @examplesIf there_is_provider() && nchar(Sys.getenv("ENTSOE_PAT")) > 0L
#' @examplesIf there_is_provider()
#' eic_tie_line <- entsoeapi::tie_line_eic()
#'
#' dplyr::glimpse(eic_tie_line)
Expand Down Expand Up @@ -159,7 +161,7 @@ tie_line_eic <- function() {
#'
#' @export
#'
#' @examplesIf there_is_provider() && nchar(Sys.getenv("ENTSOE_PAT")) > 0L
#' @examplesIf there_is_provider()
#' eic_location <- entsoeapi::location_eic()
#'
#' dplyr::glimpse(eic_location)
Expand Down Expand Up @@ -191,7 +193,7 @@ location_eic <- function() {
#'
#' @export
#'
#' @examplesIf there_is_provider() && nchar(Sys.getenv("ENTSOE_PAT")) > 0L
#' @examplesIf there_is_provider()
#' eic_resource_object <- entsoeapi::resource_object_eic()
#'
#' dplyr::glimpse(eic_resource_object)
Expand Down Expand Up @@ -228,7 +230,7 @@ resource_object_eic <- function() {
#'
#' @export
#'
#' @examplesIf there_is_provider() && nchar(Sys.getenv("ENTSOE_PAT")) > 0L
#' @examplesIf there_is_provider()
#' eic_substation <- entsoeapi::substation_eic()
#'
#' dplyr::glimpse(eic_substation)
Expand Down Expand Up @@ -258,9 +260,11 @@ substation_eic <- function() {
#' `MarketParticipantIsoCountryCode`, `MarketParticipantVatCode`,
#' `EicTypeFunctionList` and `type`.
#'
#' @importFrom dplyr bind_rows
#'
#' @export
#'
#' @examplesIf there_is_provider() && nchar(Sys.getenv("ENTSOE_PAT")) > 0L
#' @examplesIf there_is_provider()
#' eic_all <- entsoeapi::all_approved_eic()
#'
#' dplyr::glimpse(eic_all)
Expand All @@ -275,41 +279,131 @@ all_approved_eic <- function() {
resource_object_eic(),
substation_eic()
) |>
dplyr::bind_rows() |>
bind_rows() |>
unique() |>
tibble::as_tibble()
as_tbl()
}


#' @title
#' Get all Allocated Energy Identification Codes
#'
#' @description
#' Beware, this is a REAL SLOW function, it runs for ages!
#' Be patient!!
#' Beware, this is a REAL SLOW function, it runs for minutes, be patient!
#' This function downloads all allocated
#' energy identification codes from this link:
#' https://eepublicdownloads.blob.core.windows.net/
#' cio-lio/xml/allocated-eic-codes.xml
#' Further details are under:
#' https://www.entsoe.eu/data/energy-identification-codes-eic/
#' It is an alternative of `all_approved_eic()` function call
#' providing more details.
#'
#' @export
#'
#' @return
#' A tibble of all allocated EIC codes, which contains such columns as
#' `doc_status`, `doc_status_value`, `revision_number`, `created_date_time`,
#' `eic_code`, `instance_component_attribute`, `long_name`, `display_name`,
#' `last_request_date`, `eic_code_deactivation_requested_date_and_or_time_date`,
#' `description`, `eic_code_market_participant_vat_code_name`,
#' `eic_code_market_participant_acer_code_name` and
#' `parent_market_document_mrid`
#' `revision_number`, `created_date_time`, `eic_code`, `doc_status_value`,
#' `doc_status`, `instance_component_attribute`, `long_name`, `display_name`,
#' `last_request_date`, `deactivation_requested_date_and_or_time_date`,
#' `eic_code_market_participant_street_address`,
#' `market_participant_vat_code_name`, `market_participant_acer_code_name`,
#' `description`, `responsible_market_participant_mrid`, `function_names`
#' and `parent_market_document_mrid`
#'
#' @importFrom stats setNames
#' @examplesIf there_is_provider()
#' eic_all <- entsoeapi::all_allocated_eic()
#'
#' dplyr::glimpse(eic_all)
#'
#' @noRd
all_allocated_eic <- function() {
cache_get_or_compute( # nolint: object_usage_linter
key = "all_allocated_eic_df_key",
label = "all_allocated_eic table",
compute_fn = get_all_allocated_eic
)
}


#' @title
#' Display the ENTSO-E Transparency Platform news feed
#'
#' @description
#' Fetches the RSS news feed from the ENTSO-E Transparency Platform and
#' displays the entries in the console. Useful for checking platform
#' maintenance windows, data publication delays, and other announcements
#' that may affect API availability.
#'
#' @param feed_url the URL of the RSS news feed from the ENTSO-E
#' Transparency Platform.
#' @param n Integer scalar. Maximum number of feed items to display.
#' Defaults to `5L`. Use `Inf` to show all items.
#'
#' @return A tibble of feed items with columns `title`, `pub_date`, and
#' `description`, returned invisibly.
#'
#' @export
#'
#' @importFrom httr2 request req_method req_user_agent req_timeout req_retry
#' resp_body_xml
#' @importFrom xml2 xml_find_all xml_find_first xml_text read_html
#' @importFrom cli cli_h1 cli_h2 cli_text cli_alert_info
#'
#' @examplesIf there_is_provider()
#' entsoeapi::get_news()
#'
get_news <- function(feed_url = .feed_url, n = 5L) {
resp <- feed_url |>
request() |>
req_method(method = "GET") |>
req_user_agent(string = user_agent_string) |>
req_timeout(seconds = 30L) |>
req_retry(
max_tries = 3L,
is_transient = \(resp) resp_status(resp) == 503L,
backoff = \(x) 10
) |>
req_perform()

feed_xml <- resp_body_xml(resp = resp)
items <- xml_find_all(x = feed_xml, xpath = "//item")

n_show <- min(length(items), n)

titles <- character(n_show)
dates <- character(n_show)
descriptions <- character(n_show)

cli_h1("ENTSO-E Transparency Platform News")

for (i in seq_len(n_show)) {
titles[[i]] <- xml_find_first(items[[i]], "title") |>
xml_text()
dates[[i]] <- xml_find_first(items[[i]], "pubDate") |>
xml_text()
raw_desc <- xml_find_first(items[[i]], "description") |>
xml_text()
descriptions[[i]] <- tryCatch(
expr = {
paste0("<body>", raw_desc, "</body>") |>
read_html() |>
xml_text() |>
trimws()
},
error = \(e) trimws(raw_desc)
)

cli_h2("{titles[[i]]}")
cli_alert_info("{dates[[i]]}")
cli_text("{descriptions[[i]]}")
}

result <- data.frame(
title = titles,
pub_date = dates,
description = descriptions
) |>
as_tbl()

invisible(result)
}
5 changes: 3 additions & 2 deletions R/en_market.R
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ continuous_offered_transfer_capacity <- function( # nolint: object_length_linter
implicit_offered_transfer_capacities <- function( # nolint: object_length_linter
eic_in = NULL,
eic_out = NULL,
period_start = lubridate::ymd(Sys.Date() - lubridate::days(x = 1L),
period_start = lubridate::ymd(
x = Sys.Date() - lubridate::days(x = 1L),
tz = "CET"
),
period_end = lubridate::ymd(Sys.Date(),
Expand Down Expand Up @@ -1160,7 +1161,7 @@ net_positions <- function(
#' can be checked from contract_types table;
#' "A01" = Day ahead
#' "A02" = Weekly
#' "A032 = Monthly
#' "A03" = Monthly
#' "A04" = Yearly
#' "A06" = Long Term
#' "A07" = Intraday
Expand Down
Loading
Loading