| Title: | Access the Swedish Code of Statutes via Riksdagen's Open Data |
| Version: | 0.1.0 |
| Description: | Provides functions to search and retrieve the consolidated text of Swedish statutes (Svensk författningssamling, SFS) via the Riksdag's open data API. Part of the lexverse ecosystem of packages for accessing legal and regulatory data. |
| Depends: | R (≥ 4.1.0) |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 8.0.0 |
| Imports: | cli, httr2, stats, tibble, utils |
| Suggests: | knitr, rmarkdown, spelling, testthat (≥ 3.0.0), urlchecker |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| Language: | en-US |
| NeedsCompilation: | no |
| Packaged: | 2026-07-30 10:29:56 UTC; kristianvepsalainen |
| Author: | Kristian Vepsäläinen [aut, cre] |
| Maintainer: | Kristian Vepsäläinen <kristian.vepsalainen@proton.me> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-07 17:10:02 UTC |
Get a Swedish statute (SFS) document
Description
Retrieves the consolidated, up-to-date text and metadata of a Swedish statute from Riksdagen's open data API.
Usage
swe_get_doc(sfs_nr)
Arguments
sfs_nr |
Character. SFS number in the format "1974:152". |
Value
A one-row tibble with columns: sfs_nr, titel, departement,
utfardad, andrad_tom, upphavd, upphavd_av, is_repealed, text.
Get metadata for a Swedish statute, without the full text
Description
A thin wrapper around swe_get_doc() that drops the text column.
Note: this still performs the same API call as swe_get_doc() — the
underlying endpoint does not support a text-free response — so it is a
convenience wrapper, not a lighter-weight one. See ROADMAP.md for a
possible future optimisation via the dokumentlista endpoint.
Usage
swe_get_metadata(sfs_nr)
Arguments
sfs_nr |
Character. SFS number in the format "1974:152". |
Value
A one-row tibble with columns: sfs_nr, titel, departement,
utfardad, andrad_tom, upphavd, upphavd_av, is_repealed.
Get the consolidated text of a Swedish statute
Description
A thin wrapper around swe_get_doc() that returns only the text.
Usage
swe_get_text(sfs_nr)
Arguments
sfs_nr |
Character. SFS number in the format "1974:152". |
Value
Character. The consolidated statute text.
Check whether a Swedish statute has been repealed
Description
A thin wrapper around swe_get_doc().
Usage
swe_is_repealed(sfs_nr)
Arguments
sfs_nr |
Character. SFS number in the format "1974:152". |
Value
Logical. TRUE if repealed, FALSE otherwise.
Search Swedish statutes (SFS)
Description
Searches Riksdagen's open data for statutes matching free text, a date
range, an issuing department, or a session year, sorted by relevance.
Unlike swe_get_doc(), an empty result set is not an error — it simply
means no statutes matched.
Usage
swe_search(
query = NULL,
from_date = NULL,
to_date = NULL,
org = NULL,
rm = NULL,
max_results = 50
)
Arguments
query |
Character. Free-text search term, matched against title and body text. Optional. |
from_date, to_date |
Character or Date, format "YYYY-MM-DD". Restrict to statutes issued within this range. Optional. |
org |
Character. Filter by issuing department/authority, e.g. "Justitiedepartementet". Optional. |
rm |
Character. Filter by Riksdag session year, e.g. "2022". Optional. |
max_results |
Integer. Maximum number of results to return. Default 50. |
Value
A tibble with columns: sfs_nr, titel, departement, datum,
dok_id, summary, score. Zero rows if nothing matched. Sorted by
relevance (descending) when query is supplied.