MyNixOS website logo
Description

'Fingrid Open Data API' R Client.

R API client package for 'Fingrid Open Data' <https://data.fingrid.fi/> on the electricity market and the power system. get_data() function holds the main application logic to retrieve time-series data. API calls require free user account registration. Data is made available by Fingrid Oyj and distributed under Creative Commons 4.0 <https://creativecommons.org/licenses/by/4.0/>.

finnishgrid

The goal of finnishgrid is to provide an easy one-liner access to all Fingrid Open Data API functions.

Installation

You can install the development version of finnishgrid from GitHub with:

# install.packages("devtools")
# required dependencies httr and jsonlite
# install.packages(c("httr", "jsonlite"))
devtools::install_github("virmar/finnishgrid")

Free API registration

Read basic API specification at https://data.fingrid.fi/en/instructions and register free user account.

Optional: add API key as your environment variable (~/.Renviron)

FINGRID_OPENDATA_API_KEY=MY_SECRET_KEY_FROM_API_PAGES

Example

Let’s get Finnish hourly electricity consumption and production time-series data for basic visualization.

library(finnishgrid)
start_time_utc = "2024-06-01T00:00:00.000Z"
end_time_utc = "2024-06-03T00:00:00.000Z"
user_key = NA  # TODO: replace with right key or use .Renviron file

Fetching data with helper functions

elec_cons <- powersys_electricity_consumption_FI_RTD(start_time_utc = start_time_utc,
                                            end_time_utc = end_time_utc,
                                            user_key = user_key)
Sys.sleep(1)

elec_prod <- powersys_electricity_production_FI_RTD(start_time_utc = start_time_utc,
                                           end_time_utc = end_time_utc,
                                           user_key = user_key)
Sys.sleep(1)

min_elec_cons <- min(elec_cons$value)  # consumption
max_elec_cons <- max(elec_cons$value)

min_elec_prod <- min(elec_prod$value)  # production
max_elec_prod <- max(elec_prod$value)

y_max <- max(max_elec_cons, max_elec_prod)
y_min <- min(min_elec_cons, min_elec_prod)

Basic data visualization

plot(elec_cons$start_time, elec_cons$value, type = 'l',
     col = "green", ylim = c(y_min, y_max),
     ylab = "Produced/Consumed (MW)",
     xlab = "Time", main = "Electricity",
     sub = "Data source Fingrid / data.fingrid.fi, license CC 4.0 BY")
lines(elec_prod$start_time, elec_prod$value, type = 'l', col = "blue")
legend("topright", c("Cons", "Prod"), fill = c("green", "blue"))

Get electricity consumption in Finland with get_data() function

API page: https://data.fingrid.fi/en/datasets/124

tmp <- get_data(api_number = 193,  # energy consumption
                start_time = start_time_utc, 
                end_time = end_time_utc, 
                user_key = NA)
summary(tmp)
#>  start_time_utc                 end_time_utc                     value     
#>  Min.   :2024-06-01 00:00:00   Min.   :2024-06-01 00:03:00   Min.   :6434  
#>  1st Qu.:2024-06-01 11:59:15   1st Qu.:2024-06-01 12:02:15   1st Qu.:6914  
#>  Median :2024-06-01 23:58:30   Median :2024-06-02 00:01:30   Median :7441  
#>  Mean   :2024-06-01 23:58:30   Mean   :2024-06-02 00:01:30   Mean   :7347  
#>  3rd Qu.:2024-06-02 11:57:45   3rd Qu.:2024-06-02 12:00:45   3rd Qu.:7726  
#>  Max.   :2024-06-02 23:57:00   Max.   :2024-06-03 00:00:00   Max.   :8166  
#>        id     
#>  Min.   :193  
#>  1st Qu.:193  
#>  Median :193  
#>  Mean   :193  
#>  3rd Qu.:193  
#>  Max.   :193
Metadata

Version

0.2.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows