Altinn.Codelists 9.0.0-preview.1

This is a prerelease version of Altinn.Codelists.
dotnet add package Altinn.Codelists --version 9.0.0-preview.1
                    
NuGet\Install-Package Altinn.Codelists -Version 9.0.0-preview.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Altinn.Codelists" Version="9.0.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Altinn.Codelists" Version="9.0.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="Altinn.Codelists" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Altinn.Codelists --version 9.0.0-preview.1
                    
#r "nuget: Altinn.Codelists, 9.0.0-preview.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Altinn.Codelists@9.0.0-preview.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Altinn.Codelists&version=9.0.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Altinn.Codelists&version=9.0.0-preview.1&prerelease
                    
Install as a Cake Tool

Altinn Common Codelists

GitHub release (latest SemVer including pre-releases) GitHub last commit GitHub

This library contains common code lists for use in Altinn 3 based applications.

The Getting started section describes the basic steps required in order to use this package within an Altinn 3 application. For a more comprehensive description of code lists in Altinn 3 please see https://docs.altinn.studio/app/development/data/options/. <hr> <br/>

Getting started using the package

This guide assumes you have an existing Altinn 3 application. If not please see https://docs.altinn.studio/app/getting-started/create-app/ to get started.

1. Add reference to Altinn.Codelists nuget package

Open command line to the repo of your application and navigate to the App folder where the App.csproj file is located and run the following command:

dotnet add package Altinn.Codelists

This will add the latest stable version of the package to your solution.

As an alternative you can edit your applications App.csproj file directly by adding the reference below to the <itemgroup> where you have package references.

  <PackageReference Include="Altinn.Codelists" Version="0.5.0" />     

Note that you then need to explicitly specify the version you would like. See the link on step one for available versions.

2. Register the codelists in your app DI container

Add the following to your Program.cs file:

services.AddAltinnCodelists();

By calling this you will register all codelists across all sources listed below in available codelists. You can also register codelists one by one if you for example would like to provide your own codelist id, or if you would like to control the mappings to description and help texts.

3. Connect your application to the codelist you would like to use

See the section below for available codelist id's.

You can either do this using Altinn Studio and configure the Kodeliste-ID of your component in the UI.

Or you can configure the component by editing the optionsId property in FormLayout.json according to the documentation

Custom configuration

While the above mentioned configuration where you call services.AddAltinnCodelists(); will add all available codelists with default values, there are cases where you might want to customize the configuration. The examples will vary a bit depending on the source of the codelist.

Add a codelist with custom codelist id

If you don't want to use the default codelist id, or only want to register codelists relevant for you app you can register each codelist individually.

Example using codelist from SSB overriding the option id:

   services.AddSSBClassificationCodelistProvider("næring", Classification.IndustryGrouping);

Add a codelist with default parameters

Some of the codelists accepts parameters controlling what's returned.

Example using the codelist from SSB specifying a level filter to only get values from the first level (this particular codelist is hierarchical).

   services.AddSSBClassificationCodelistProvider("næring", Classification.IndustryGrouping, new Dictionary<string, string>() { { "level", "1" } });

The default parameters is a name/value pair collection allowing for any parameter to be passed in and picked up by the implementation of the codelist provider.

Add a codelist that has support for description and/or help text values

While a regular codelist is only key/value pairs, you can extend this with adding description and help text allowing for a more descriptive UI.

The following example enables the notes field from SSB classification to populate the description text.

    services.AddSSBClassificationCodelistProvider("næring", Classification.IndustryGrouping,
        new ClassificationOptions() { MapNotesToDescription = true },
        new Dictionary<string, string>() { { "level", "1" } });

The above example enables a predefined way of adding a description text. If you would like to customize the description text even further you can pass inn a function. The following examples passes in a function that that will be evaluated when populating the code list and will return a combination of the classification code and the notes fields separated by colon.

services.AddSSBClassificationCodelistProvider(
        "næring",
        Classification.IndustryGrouping,
        new ClassificationOptions() 
        { 
            MapDescriptionFunc = (classificationCode) => $"{classificationCode.Code}: {classificationCode.Notes}" 
        },
        new Dictionary<string, string>() { { "level", "1" } });

Add a codelist from SSB not available in the Classification enum.

Currently only a small subset of the available codelist from SSB is included in the Classification enum. The enum is really only provided as a more readable version of the underlying id provided by SSB. But in our case also serves as a way of telling what codelists we have tested explicitly against. If you find a codelist you would like to use, you can specify it's id instead of the enum.

   services.AddSSBClassificationCodelistProvider("næring", 6);

Available codelists

The list below shows currently implemented code lists with their default id.

Default Codelist Id Source Description
fylker SSB The counties of Norway
fylker-kv Kartverket The counties of Norway
grunnbeløpfolketrygden SSB National insurance base amount
kjønn SSB Sex
kommuner SSB The communes of Norway (all)
kommuner-kv Kartverket The communes of Norway with ability to filter on county
land SSB The countries of the world
næringsgruppering SSB Industrical grouping
poststed Posten Norwegian postal codes
sivilstand SSB Marital status
yrker SSB Occupations

Sources

Below are the sources used for the various codelists above. The underlying api's provide different functionality with regards to query parameters. Espessialy the SSB api's provide a rich set of parameters allowing the query for valid values on a given date or date range.

Statistisk Sentralbyrå/SSB

Doc: https://data.ssb.no/api/klass/v1/api-guide.html

License: https://data.ssb.no/api/klass/v1/api-guide.html#_license

Kartverket/KV

Doc: https://kartkatalog.geonorge.no/metadata/administrative-enheter-kommuner/041f1e6e-bdbc-4091-b48f-8a5990f3cc5b

Api: https://ws.geonorge.no/kommuneinfo/v1/

License: https://www.kartverket.no/api-og-data/vilkar-for-bruk

Posten

Doc: https://www.bring.no/tjenester/adressetjenester/postnummer/postnummertabeller-veiledning

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

Altinn Apps development team - If you want to get in touch, just create a new issue. See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License. See the repository root LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Altinn.Codelists:

Package Downloads
PsA3Forms

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.0-preview.1 38 9/9/2026
8.0.3 1,580 2/18/2026
8.0.2 2,742 10/1/2025
8.0.1 1,239 9/19/2025
8.0.0 364 9/18/2025
8.0.0-rc.1 210 7/2/2025
0.8.0 6,581 11/6/2024
0.7.0 6,738 10/19/2023
0.6.2 961 5/22/2023
0.6.1 1,948 5/16/2023
0.6.0 329 5/16/2023
0.5.1 359 5/16/2023
0.5.0 373 5/15/2023
0.5.0-preview.9 261 5/4/2023
0.5.0-preview.8 236 5/2/2023
0.5.0-preview.7 317 3/20/2023
0.5.0-preview.6 284 3/14/2023
0.5.0-preview.5 259 3/14/2023
0.5.0-preview.4 267 3/14/2023
0.5.0-preview.3 246 3/10/2023
Loading failed