Skip to content

Add access to Lovdata's free open data packages #9

Description

Lovdata publishes current Norwegian acts and central regulations as free open data under NLOD 2.0, with no account and no API key required. This is the part of Lovdata most people can actually use — a researcher, a journalist, or a developer building a local index does not need a commercial agreement to get the full corpus. The module today requires a stored API key for everything, so the free datasets, which are the most accessible thing Lovdata offers, are the one thing it cannot reach.

Request

Desired capability

Commands that list the public data packages Lovdata publishes and download one to disk, without any credential. A user should be able to install the module and pull the full set of Norwegian acts in two commands, then unpack and process them locally.

Acceptance criteria

  • The available public data packages can be listed with no API key stored
  • A package can be downloaded to a chosen directory with no API key stored
  • Downloading reports progress, because the packages are large
  • An existing file is not silently overwritten unless the caller asks for it
  • The NLOD 2.0 licence and the requirement to credit Lovdata are stated in the command help, not only in the README
  • Tests pass without an API key

References


Technical decisions

Code placement: New group src/functions/public/PublicData/ with a PublicData.md overview that carries the licence and attribution text.

Command naming: Get-LovdataPublicDataset for the list and Save-LovdataPublicDataset for the download. Save- is the approved verb for writing to a file.

Anonymous access: These endpoints need no key, so they build on the anonymous transport mode from #8 rather than adding a second unauthenticated path. When a context happens to be stored, using it is harmless; when none is stored the commands must still work, which is the behaviour worth testing.

Large downloads: The packages are tens of megabytes. Stream to disk rather than buffering the body in memory, and use the progress stream so a caller sees the transfer. This is a different code path from the JSON transport, so it belongs beside it in src/functions/private/API/ rather than inside the public command.

Overwrite behaviour: Refuse to overwrite an existing file unless -Force is given, consistent with how PowerShell file-producing commands behave.

Test approach: Unit tests mocking the download helper, covering listing, target path construction, and overwrite refusal. No multi-megabyte download in unit tests.

Depends on: the anonymous transport mode in #8. The pull request targets build-lovdata-module.


Implementation plan

Core changes

  • Add a streaming download helper under src/functions/private/API/
  • Add Get-LovdataPublicDataset under src/functions/public/PublicData/
  • Add Save-LovdataPublicDataset under src/functions/public/PublicData/
  • Add the PublicData.md group overview page with the NLOD 2.0 licence and attribution

Tests

  • Add a test for listing packages with no context stored
  • Add a test for the download target path
  • Add a test that an existing file is not overwritten without -Force

Documentation

  • Add an open-data example under examples/
  • Mention the credential-free path in the README

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew featureminorNew feature or enhancement, version 0.x.0 increase

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions