Retrieves a document from the generic document endpoint of the Finlex Open Data API (/akn/fi/doc/...), which covers document types that are not part of the Statute Book of Finland: treaties, government proposals, authority regulations, and certain collective agreements.

flx_get_doc(doc_type, year, number)

Arguments

doc_type

Character, length 1. One of "authority-regulation", "treaty", "tax-treaty-consolidated", "government-proposal", "collective-agreement-general-applicability-decision", or "trade-union-center-agreement". Call this function separately for different document types.

year

Integer vector. Year(s) of the document(s).

number

Character or integer vector. Number(s) of the document(s) within that year. Recycled against year if shorter. Accepts character because document numbers in these collections are not always simple integers.

Value

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

doc_type

As supplied.

year

As supplied.

number

As supplied.

status

One of "ok", "pdf_only" (the document exists but has no machine-readable text, only a scanned/original PDF), "not_found", or "error".

title

The document's official title.

date_issued

Date the document was issued, as a Date.

text

The full body text of the document, or NA if only a PDF is available.

pdf_url

URL of the document's PDF version. Populated for both "ok" and "pdf_only" statuses.

Details

Unlike flx_get_text(), this function does not split the document into sections. The document types covered here (treaties, government proposals, agreements) do not share a consistent internal structure the way statutes do, so the full body text is returned as a single block.

Some documents, particularly older ones, have never been digitised as machine-readable text and exist only as a scanned or original PDF. For these, status is "pdf_only", text is NA, and pdf_url points to the PDF so the content is still reachable.

Two document types available in the underlying API are intentionally not covered by this function: "treaty-metadata" (a lighter reference record rather than a full document) and "legal-literature-references" (an index of literature discussing case law, not the case law itself). Both likely need bespoke handling and may be added in a future version.

Examples

# \donttest{
flx_get_doc(
  doc_type = "authority-regulation",
  year = 1996, number = 32082
)
#> # A tibble: 1 × 8
#>   doc_type              year number status   title     date_issued text  pdf_url
#>   <chr>                <int> <chr>  <chr>    <chr>     <date>      <chr> <chr>  
#> 1 authority-regulation  1996 32082  pdf_only Kolin ka… 1996-11-18  NA    https:…
# }