| Title: | Access Open Data from the Finnish 'Finlex' Legislative Database |
|---|---|
| Description: | Provides functions to retrieve and structure Finnish legislative data made available through the 'Finlex' Open Data API (<https://www.finlex.fi/en/open-data>). Functions cover retrieval of statute catalogues, statute titles, structured statute metadata, and cross-references between amending and amended statutes, returned as tidy tibbles for further analysis. |
| Authors: | Kristian Vepsäläinen [aut, cre] |
| Maintainer: | Kristian Vepsäläinen <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-07-22 12:24:27 UTC |
| Source: | https://github.com/cran/finlex |
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 )flx_download_statutes( start_year = 1987, end_year = as.integer(format(Sys.Date(), "%Y")), categories = c("new-statute", "amending-statute", "repealing-statute"), quiet = FALSE )
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 |
quiet |
Logical. If |
A tibble::tibble() with one row per statute and the columns:
The Akoma Ntoso URI identifying the statute.
Year of the statute, as an integer.
Statute number within that year, as an integer.
One of "NewStatute", "Amendment", "Repeal".
Returns a zero-row tibble with the same columns if nothing matches.
flx_download_statutes( start_year = 2023, end_year = 2023, categories = "new-statute" )flx_download_statutes( start_year = 2023, end_year = 2023, categories = "new-statute" )
For a given amending or repealing statute, retrieves the statute(s) it
affects (the affectedDocument references in the Akoma Ntoso
document). A single amending statute can affect more than one target
statute (for example, an omnibus act amending several other acts), in
which case one row is returned per affected target.
flx_get_affected(year, number)flx_get_affected(year, number)
year |
Integer vector. Year(s) of the amending/repealing statute(s). |
number |
Integer vector. Number(s) of the statute(s) within that
year. Recycled against |
This function does not check whether the supplied statute is actually
an amendment or repeal; it simply looks for affectedDocument
references in whatever statute is requested. New statutes will
typically return status = "no_affected".
A tibble::tibble() with the columns:
Year of the amending/repealing statute, as supplied.
Number of the amending/repealing statute, as supplied.
One of "ok" (at least one affected statute found),
"no_affected" (statute found, but no affected-document
references present), "not_found", or "error".
URI of the affected statute, or NA.
Year of the affected statute, or NA.
Number of the affected statute, or NA.
# Look up affected statutes for a known amending statute flx_download_statutes( start_year = 2023, end_year = 2023, categories = "amending-statute" ) |> head(1) |> with(flx_get_affected(year, number))# Look up affected statutes for a known amending statute flx_download_statutes( start_year = 2023, end_year = 2023, categories = "amending-statute" ) |> head(1) |> with(flx_get_affected(year, number))
Retrieves core bibliographic metadata for one or more Finnish statutes from the Finlex Open Data API: the date of issue, the official title, and the number of sections (Finnish: pykälät) in the statute text.
flx_get_metadata(year, number)flx_get_metadata(year, number)
year |
Integer vector. Year(s) of the statute(s). |
number |
Integer vector. Number(s) of the statute(s) within that
year. Recycled against |
This function intentionally returns only raw, directly observed fields. Any derived classification (for example, grouping statutes into categories such as "Act", "Decree", or "Decision" based on title patterns) is left to a separate function, since that involves methodological choices rather than data retrieval.
A tibble::tibble() with one row per (year, number) pair and
the columns:
As supplied.
As supplied.
One of "ok", "not_found", or "error".
Date the statute was issued, as a Date.
The statute's official title.
Integer. Number of section elements found in the
Akoma Ntoso document — a rough, purely structural proxy for
statute length.
flx_get_metadata(year = 1992, number = 1535) # Tuloverolakiflx_get_metadata(year = 1992, number = 1535) # Tuloverolaki
Retrieves the official title of one or more Finnish statutes from the Finlex Open Data API, given each statute's year and number.
flx_get_title(year, number)flx_get_title(year, number)
year |
Integer vector. Year(s) of the statute(s). |
number |
Integer vector. Number(s) of the statute(s) within that
year. Recycled against |
Not every statute in Finnish legal history is available through the
Finlex Open Data API (very old statutes in particular are not covered).
When a statute cannot be found, status is set to "not_found" rather
than raising an error, so that vectorized calls complete even when some
statutes are missing.
A tibble::tibble() with one row per (year, number) pair and
the columns:
As supplied.
As supplied.
One of "ok", "not_found", or "error".
The statute's official title, or NA if unavailable.
flx_get_title(year = 1992, number = 1535) # Tuloverolaki flx_get_title(year = c(1992, 1993), number = c(1535, 1501))flx_get_title(year = 1992, number = 1535) # Tuloverolaki flx_get_title(year = c(1992, 1993), number = c(1535, 1501))