Retrieves the list of Finnish statutes (Finnish: säädökset) published via the Finlex Open Data REST API (https://www.finlex.fi/en/open-data), for a given range of years and statute categories. Only the Finnish-language (fin) version of each statute is returned.

flx_download_statutes(
  start_year = 1987,
  end_year = as.integer(format(Sys.Date(), "%Y")),
  categories = c("new-statute", "amending-statute", "repealing-statute"),
  quiet = FALSE
)

Arguments

start_year

Integer. First year to include. The Finlex Open Data API currently starts from 1987.

end_year

Integer. Last year to include. Defaults to the current year.

categories

Character vector. One or more of "new-statute", "amending-statute", "repealing-statute". Defaults to all three.

quiet

Logical. If FALSE (the default), prints one progress message per year processed.

Value

A tibble::tibble() with one row per statute and the columns:

akn_uri

The Akoma Ntoso URI identifying the statute.

year

Year of the statute, as an integer.

number

Statute number within that year, as an integer.

statute_type

One of "NewStatute", "Amendment", "Repeal".

Returns a zero-row tibble with the same columns if nothing matches. If the Finlex API becomes unreachable partway through (network outage, timeout, or server error), the function stops downloading, prints an informative message, and returns whatever was successfully retrieved so far, rather than raising an error.

Examples

# \donttest{
flx_download_statutes(
  start_year = 2023,
  end_year   = 2023,
  categories = "new-statute"
)
#> Year 2023 done (388 rows so far)
#> # A tibble: 388 × 4
#>    akn_uri                                              year number statute_type
#>    <chr>                                               <int>  <int> <chr>       
#>  1 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023    657 NewStatute  
#>  2 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023      4 NewStatute  
#>  3 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023      1 NewStatute  
#>  4 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023      6 NewStatute  
#>  5 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023      5 NewStatute  
#>  6 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023      9 NewStatute  
#>  7 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023      7 NewStatute  
#>  8 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023     63 NewStatute  
#>  9 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023     64 NewStatute  
#> 10 https://opendata.finlex.fi/finlex/avoindata/v1/akn…  2023     65 NewStatute  
#> # ℹ 378 more rows
# }