Skip to main content

ssb-klass-python / KLASS

PyPI Status Python Version License

Documentation Tests Coverage Quality Gate Status

pre-commit Black Ruff Poetry

A Python package built on top of Statistics Norway's code- and classification-system "KLASS".
The package aims to make Klass's API for retrieving data easier to use by re-representing Klass's internal hierarchy as python-classes. Containing methods for easier traversal down, search classes and widgets, reasonable defaults to parameters etc. Where data is possible to fit into pandas DataFrames, this will be preferred, but hiererachical data / objects containing metadata will be kept as json / dict structure.

Installing

The package is available on Pypi, and can be installed by for example poetry like this:

poetry add ssb-klass-python

Example usages

Getting started

from klass import search_classification
# Opens a ipywidget in notebooks for searching for classifications and copying code, to get started
search_classification(no_dupes=True)

The GUI available through the search_classification function

Getting a classification directly

from klass import get_classification # Import the utility-function
nus = get_classification(36)
# Does the same as the code above, but does not shy away from using the class directly
from klass import KlassClassification # Import the class for KlassClassifications
nus = KlassClassification(36)  # Use ID for classification

When you have the classification stored in an object, you can "dig into" the API from there.

codes = nus.get_codes() # codes from current date
print(codes)
codes.data  # Pandas dataframe available under the .data attribute

From searching through "families", down to a specific codelist

from klass import KlassSearchFamilies
search = KlassSearchFamilies(360)
print(search)
>>> "Family ID: 20 - Utdanning - Number of classifications: 5"
utdanning = search.get_family(20)
print(utdanning)
>>> "The Klass Family "Utdanning" has id 20."
>>> "And contains the following classifications:"
>>>  "36: Standard for utdanningsgruppering (NUS)"
nus = utdanning.get_classification(36)
print(nus)
>>> "Classification 36: Standard for utdanningsgruppering (NUS)..."
nus_codes = nus.get_codes("2023-01-01")
print(nus_codes)
>>> "Codelist for classification: 36"
>>> " From date: 2023-01-01"
nus_codes.data  # A pandas dataframe

For more examples check out the demo-notebooks in the demo/ folder in the repo.

Technical notes

Documentation for the endpoints we are using can be found on Statistics Norways pages.

Technical architecture of the API we are interacting with is detailed in Statistics Norway's internal wiki.

This project has been migrated to follow the SSB PyPI Template from Statistics Norway.

Metadata

Release files for ssb-klass-python 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssb-klass-python 1.0.8
File Size Uploaded
ssb_klass_python-1.0.8.tar.gz 30.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ssb-klass-python 1.0.8
File Interpreter ABI Platform
ssb_klass_python-1.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 68.2 kB

Release files / ssb_klass_python-1.0.8.tar.gz

Download URL ssb_klass_python-1.0.8.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0e5c1d0fd709256f68d3a658fe2b7d376882f59a4cb6ea1c854e09e1f4f68f53
BLAKE2b-256 checksum
How to use checksums
2a5595d19215ceaae7a6708edd4cb17d88018a3227761b78d886fc216b5e70bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.

Transparency log

Release files / ssb_klass_python-1.0.8-py3-none-any.whl

Download URL ssb_klass_python-1.0.8-py3-none-any.whl
Size 37.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7506c0ab0aefb93d6e82ef630d825133d8a9890671b9df355cd69c3adabb65b5
BLAKE2b-256 checksum
How to use checksums
83053725538c26d70e9d07f734fdf07cd87185f687c23dc675334024f040134d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.8 This release

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.11

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page