Metadata-Version: 2.5
Name: dataportalen
Version: 0.3.0
Summary: dataportal.se as plain Python dicts: DCAT-AP-SE metadata with vocabulary URIs resolved to labels
Project-URL: Homepage, https://github.com/nordicintel/dataportal
Project-URL: Documentation, https://docs.dataportal.se/registry/api/
Author: Nordic Intel
License: MIT
License-File: LICENSE
Keywords: dataportal,dcat,dcat-ap-se,entrystore,open-data,rdf,sweden
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24
Requires-Dist: requests>=2.25
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.16; extra == 'dev'
Description-Content-Type: text/markdown

# dataportalen

Python access to [dataportal.se](https://www.dataportal.se) that gives you
**plain dicts, not RDF**.

Sweden's open-data registry describes its 23,500 datasets in RDF, which means
every value arrives as a web address: a dataset about roads is filed under
`http://publications.europa.eu/resource/authority/data-theme/TRAN` rather than
under "transport". Working out that it means "transport" is, per the
[registry's own documentation](https://docs.dataportal.se/registry/api/), your
problem.

This package makes it not your problem. You search with words and you get
dictionaries back.

## Install

```bash
pip install dataportalen
```

Distribution and import name are both `dataportalen`. The unrelated
`dataportal` package on PyPI is a Korean public-data client — not this.

## Search

```python
from dataportalen import Dataportal

with Dataportal(language="sv") as dp:      # "en", or "all" for every language
    page = dp.datasets(theme="transport", publisher="trafikverket",
                       updated_after="2024-01-01")
    print(page.total)
    for dataset in page:
        print(dataset.to_dict())
```

```json
{
  "uri": "https://example.org/data/roads",
  "title": "Vägtrafiknät",
  "themes": ["transport"],
  "license": "cc_by_4_0",
  "access_rights": "public",
  "accrual_periodicity": "annual",
  "publisher": {"name": "Trafikverket", "type": "national_authority"},
  "distributions": [
    {"download_url": ["https://...csv"], "format": "csv"}
  ]
}
```

## The whole catalogue in one file

```python
from dataportalen import download_catalog

download_catalog("catalog.jsonl")
# 23,580 datasets · 35,151 distributions · 58 MiB · ~6 minutes
```

One dataset per line, distributions and publisher already nested, with a live
progress line while it runs.

## Documentation

- **[docs/guide.md](docs/guide.md)** — how to use it: searching, what comes
  back, the catalogue download, settings, async.
- **[docs/internals.md](docs/internals.md)** — how it is built: where the short
  values come from, module layout, development, releasing.

## Licence

Code is MIT. The bundled label table is third-party data redistributed under
CC BY 4.0 and EU Decision 2011/833/EU; both notices are in
[LICENSE](LICENSE), with the details in
[docs/internals.md](docs/internals.md).

Metadata you retrieve is published by its respective publishers, each under its
own licence — check the `license` field on the dataset.
