1. Overview

1.1. REST Client

Examples in this documentation use curl. The -i parameter in the examples includes the HTTP response headers. Be aware that when running Curl on MS Windows all single ' have to be replaced by double ". If Curl is not installed, an alternative is to use any REST client to explore Klass Rest interface, like Postman or address field in the browser.

1.2. URL Encoding

This API requires you to use Percent-encoding for symbols and characters that are not part of the standard unreserved URI characters.

For more information on Percent-encoding see this wikipedia article

You can also see it in use in the request example for presentationNamePattern

1.3. HTTP status codes

Klass tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP status codes.

Status code Usage

200 OK

The request completed successfully

400 Bad Request

The request was badly formed, i.e. the client has used an invalid request. The response will include an error providing further information

404 Not Found

The requested resource did not exist. The response will include an error providing further information

1.4. Errors

Whenever an error response (status code >= 400) is returned, the response will contain an error message that describes the problem. For example, a request for a non-existent classification

$ curl 'http://data.ssb.no/api/klass/v1/classifications/99999' -i

will produce a 404 Not Found response:

HTTP/1.1 404 Not Found
Content-Type: text/plain;charset=UTF-8
Content-Length: 40

Classification not found with id = 99999

1.5. Output formats

Default output format is XML. JSON is optional, and in many cases CSV. It is possible to get output in the supported output formats without using Curl -H (--header). Add the dot-prefix .json, .csv or .xml in the URL before the request parameters, e.g. json: http://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01. When adding this in the URL you only get the default character sets.

1.6. Character sets

Charset for the formats XML and JSON are UTF-8. Default charset for CSV is ISO 8859-1. This can be changed in Accept header to UTF-8.

1.7. License

We use Creative Commons Attribution 4.0 International (CC BY 4.0).

1.8. Other

In PxWebApi references to a classification in Klass has the form urn:ssb:classification:klass:ID. This can be rewritten using the classification ID to httр://data.ssb.no/api/klass/v1/classifications/ID. For questions about Statistics Norway’s APIs use: statistikkbanken@ssb.no.

2. Classification Resources

2.1. classifications

List classifications in Klass

2.1.1. Supported formats

application/json, text/xml

2.1.2. Example request (JSON)

$ curl 'http://data.ssb.no/api/klass/v1/classifications' -i \
    -H 'Accept: application/json'

2.1.3. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1272

{
  "_embedded" : {
    "classifications" : [ {
      "name" : "Standard for kommuneinndeling",
      "classificationType" : "Klassifikasjon",
      "lastModified" : "2022-09-12T13:22:32.637+0000",
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/131"
        }
      }
    }, {
      "name" : "Standard for bydelsinndeling",
      "classificationType" : "Klassifikasjon",
      "lastModified" : "2022-09-12T13:22:32.638+0000",
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/103"
        }
      }
    }, {
      "name" : "Standard for gruppering av familier",
      "classificationType" : "Klassifikasjon",
      "lastModified" : "2022-09-12T13:22:32.638+0000",
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/17"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications"
    },
    "search" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/search{?query,includeCodelists}",
      "templated" : true
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 3,
    "totalPages" : 1,
    "number" : 0
  }
}

2.1.4. Response structure

Path Type Description

_embedded.classifications

Array

An array of Classifications

_embedded.classifications[].name

String

Classification name

_embedded.classifications[].lastModified

String

Last modification time of classification

_embedded.classifications[]._links

Object

Link to classification

_links

Object

Links to other resources

page

Object

Describes number of classifications returned, see page

Relation Description

self

The current request

search

Link to search for classifications

2.1.6. Request parameters

Parameter Description

includeCodelists

[Optional] include ssb codelists. Default is false.

changedSince

[Optional] specifies that only classifications that have been changed since changedSince shall be included in the response. For details see changedSince

Search for classifications in Klass

2.2.1. Supported formats

application/json, text/xml

2.2.2. Example request (JSON)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/search?query=kommuner' -i \
    -H 'Accept: application/json'

2.2.3. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 568

{
  "_embedded" : {
    "searchResults" : [ {
      "name" : "Standard for kommuneinndeling",
      "snippet" : "Kommuneinndelingen er en administrativ inndeling av Norge",
      "searchScore" : 8.0,
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/131"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/search?query=kommuner"
    }
  },
  "page" : {
    "size" : 0,
    "totalElements" : 1,
    "totalPages" : 1,
    "number" : 0
  }
}

2.2.4. Response structure

Path Type Description

_embedded.searchResults

Array

An array of search results

_embedded.searchResults[].snippet

String

A line containing match for the words searched

_embedded.searchResults[].searchScore

Number

Represents this classifications relevans for the search

_embedded.searchResults[]._links

Object

Link to classification that matched search

_links

Object

Links to other resources

page

Object

Describes number of classifications returned, see page

Relation Description

self

The current search

2.2.6. Request parameters

Parameter Description

query

[Mandatory] specifies search terms

includeCodelists

[Optional] include ssb codelists. Default is false.

ssbSection

[Optional] only include classifications belonging to specified SSB section when searching classifications. Default is all SSB sections

2.3. classifications by ID

Get details of a classification. To get codes from the classification use operations specified in Links

2.3.1. Supported formats

application/json, text/xml

2.3.2. Example request (JSON)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131' -i \
    -H 'Accept: application/json'

2.3.3. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 2639

{
  "name" : "Standard for kommuneinndeling",
  "classificationType" : "Klassifikasjon",
  "lastModified" : "2022-09-12T13:22:31.827+0000",
  "description" : "Kommuneinndelingen er en administrativ inndeling av kommuner i Norge",
  "primaryLanguage" : "nb",
  "copyrighted" : false,
  "includeShortName" : false,
  "includeNotes" : false,
  "contactPerson" : {
    "name" : "Ziggy Stardust",
    "email" : null,
    "phone" : null
  },
  "owningSection" : "section",
  "statisticalUnits" : [ ],
  "versions" : [ {
    "name" : "Kommuneinndeling 2014",
    "validFrom" : "2014-01-01",
    "lastModified" : "2022-09-12T13:22:31.827+0000",
    "published" : [ "nb" ],
    "_links" : {
      "self" : {
        "href" : "http://data.ssb.no/api/klass/v1/versions/1"
      }
    }
  }, {
    "name" : "Kommuneinndeling 2012",
    "validFrom" : "2012-01-01",
    "validTo" : "2014-01-01",
    "lastModified" : "2022-09-12T13:22:31.827+0000",
    "published" : [ "nb" ],
    "_links" : {
      "self" : {
        "href" : "http://data.ssb.no/api/klass/v1/versions/1"
      }
    }
  } ],
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/131"
    },
    "codes" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/131/codes{?from=<yyyy-MM-dd>,to=<yyyy-MM-dd>,csvSeparator,level,selectCodes,presentationNamePattern}",
      "templated" : true
    },
    "codesAt" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/131/codesAt{?date=<yyyy-MM-dd>,csvSeparator,level,selectCodes,presentationNamePattern}",
      "templated" : true
    },
    "variant" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/131/variant{?variantName,from=<yyyy-MM-dd>,to=<yyyy-MM-dd>,csvSeparator,level,selectCodes,presentationNamePattern}",
      "templated" : true
    },
    "variantAt" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/131/variantAt{?variantName,date=<yyyy-MM-dd>,csvSeparator,level,selectCodes,presentationNamePattern}",
      "templated" : true
    },
    "corresponds" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/131/corresponds{?targetClassificationId,from=<yyyy-MM-dd>,to=<yyyy-MM-dd>,csvSeparator}",
      "templated" : true
    },
    "correspondsAt" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/131/correspondsAt{?targetClassificationId,date=<yyyy-MM-dd>,csvSeparator}",
      "templated" : true
    },
    "changes" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/131/changes{?from=<yyyy-MM-dd>,to=<yyyy-MM-dd>,csvSeparator}",
      "templated" : true
    }
  }
}

2.3.4. Response structure

Path Type Description

name

String

Classification name

description

String

Description of classification

primaryLanguage

String

Primary language for classification

classificationType

String

Type of classification, Classification or Codelist

copyrighted

Boolean

If true, classification is copyrighted

includeShortName

Boolean

If true, indicates that classificationItems may have shortnames

includeNotes

Boolean

If true, indicates that classificationItems may have notes

contactPerson

Object

Contact person for classification

owningSection

String

Owning SSB section

statisticalUnits

Array

Statistical units assigned to classification

lastModified

String

Last time classification has been modified

versions

Array

Array of classification versions

_links

Object

Links to operations on classification

Relation Description

self

The current request

codes

Used for getting codes from the classification, see codes

codesAt

Used for getting codes from the classification valid at a specific date, see codesAt

variant

Used for getting codes from a classification variant, see variant

variantAt

Used for getting codes from a variant of the classification valid at a specific date, see variantAt

corresponds

Used for getting mappings between two classifications, see corresponds

correspondsAt

Used for getting mappings between two classifications at a specific date, see correspondsAt

changes

Used for getting changes in codes, see changes

2.3.6. Request parameters

Parameter Description

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include future versions if available. Default is false.

2.4. codes

Used to get codes from a classification. A range is specified when requesting the codes, and the response will for each code indicate its valid range (validFrom/validTo). ValidTo is optional. For more information about the range see range.
The format and character set used, can be set in the http header.

To get a snapshot of codes valid at a specified date, use codesAt

2.4.1. Supported formats

text/csv, application/json, text/xml

2.4.2. Supported character sets

UTF-8, ISO-8859-1 (csv only)

2.4.3. Example request (CSV with ISO-8859-1)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2020-01-01&to=2021-01-01&csvSeparator=;' -i \
    -H 'Accept: text/csv; charset=ISO-8859-1'

2.4.4. Example response (CSV with ISO-8859-1)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 388

"code";"parentCode";"level";"name";"shortName";"presentationName";"validFrom";"validTo";"validFromInRequestedRange";"validToInRequestedRange";"notes"
"3001";;"1";"Halden";"";"";;;"2020-01-01";"2021-01-01";""
"3002";;"1";"Moss";"";"";;;"2020-01-01";"2021-01-01";""
"3003";;"1";"Sarpsborg";"";"";;;"2020-01-01";"2021-01-01";""
"3004";;"1";"Fredrikstad";"";"";;;"2020-01-01";"2021-01-01";""

2.4.5. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1236

{
  "codes" : [ {
    "code" : "3001",
    "parentCode" : null,
    "level" : "1",
    "name" : "Halden",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  }, {
    "code" : "3002",
    "parentCode" : null,
    "level" : "1",
    "name" : "Moss",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  }, {
    "code" : "3003",
    "parentCode" : null,
    "level" : "1",
    "name" : "Sarpsborg",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  }, {
    "code" : "3004",
    "parentCode" : null,
    "level" : "1",
    "name" : "Fredrikstad",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  } ]
}

2.4.6. Request parameters

Parameter Description

from

[Mandatory] specifies beginning of range with format <yyyy-MM-dd>. For details see range

to

[Optional] specifies end of range with format <yyyy-MM-dd>. If not set means that to is indefinite. For details see range

csvSeparator

[Optional] specifies separator to be used for csv format. For details see csvSeparator

csvFields

[Optional] specifies which fields should be included in the csv output. For details see csvfields

selectCodes

[Optional] only return codes that match pattern given by selectCodes. For details see selectCodes

selectLevel

[Optional] only return codes with matching level. For details see selectLevel

presentationNamePattern

[Optional] used to build a presentationName. For details see presentationNamePattern

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include codes from the future versions if available. Default is false.

2.5. codesAt

Used to get codes from a classification. A date is specified when requesting the codes, and the response will include all codes valid at the specified date. The format and character set used, can be specified in the http header.

2.5.1. Supported formats

text/csv, application/json, text/xml

2.5.2. Supported character sets

UTF-8, ISO-8859-1 (csv only)

2.5.3. Example request (CSV with ISO-8859-1)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/104/codesAt?date=2020-01-01' -i \
    -H 'Accept: text/csv; charset=UTF-8'

2.5.4. Example response (CSV with UTF-8)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=UTF-8
Content-Length: 271

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","notes"
"03",,"1","Oslo","","",,,""
"11",,"1","Rogaland","","",,,""
"15",,"1","Møre og Romsdal","","",,,""
"18",,"1","Nordland - Nordlánnda","","",,,""
"30",,"1","Viken","","",,,""

2.5.5. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1078

{
  "codes" : [ {
    "code" : "03",
    "parentCode" : null,
    "level" : "1",
    "name" : "Oslo",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  }, {
    "code" : "11",
    "parentCode" : null,
    "level" : "1",
    "name" : "Rogaland",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  }, {
    "code" : "15",
    "parentCode" : null,
    "level" : "1",
    "name" : "Møre og Romsdal",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  }, {
    "code" : "18",
    "parentCode" : null,
    "level" : "1",
    "name" : "Nordland - Nordlánnda",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  }, {
    "code" : "30",
    "parentCode" : null,
    "level" : "1",
    "name" : "Viken",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  } ]
}

2.5.6. Request parameters

Parameter Description

date

[Mandatory] specifies codes at a certain date with format <yyyy-MM-dd>.

csvSeparator

[Optional] specifies separator to be used for csv format. For details see csvSeparator

csvFields

[Optional] specifies which fields should be included in the csv output. For details see csvfields

selectCodes

[Optional] only return codes that match pattern given by selectCodes. For details see selectCodes

selectLevel

[Optional] only return codes with matching level. For details see selectLevel

presentationNamePattern

[Optional] used to build a presentationName. For details see presentationNamePattern

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include variants of the future versions if available. Default is false.

2.6. versions by ID

Used to get a classification version by ID. The ID is shown under classifications.

2.6.1. Supported formats

text/csv, application/json, text/xml

2.6.2. Supported character sets

UTF-8, ISO-8859-1 (csv only)

2.6.3. Request parameters

Parameter Description

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include future versions if available. Default is false.

2.6.4. Example request (JSON with UTF-8)

$ curl 'http://data.ssb.no/api/klass/v1/versions/131' -i \
    -H 'Accept: application/json'

2.6.5. Response structure (JSON, XML)

Path Type Description

name

String

Version name

validFrom

String

Date the version is valid from

validTo

String

Date the version is valid to

lastModified

String

Time and date the version was last time modified at

published

Array

List of languages the version is published in

introduction

String

Version description

legalBase

String

Legal base

publications

String

Source references

derivedFrom

String

Derived from

correspondenceTables

Array

List of correspondence tables for the version

classificationVariants

Array

List of classification variants for the version

changelogs

Array

Log og changes

levels

Array

List of levels

classificationItems

Array

Array of classification items

_links

Object

Links to operations on the version

2.6.6. Response structure (JSON, XML)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1364

{
  "name" : "Kommuneinndeling 2012",
  "validFrom" : "2012-01-01",
  "validTo" : "2014-01-01",
  "lastModified" : "2022-09-12T13:22:32.757+0000",
  "published" : [ "nb" ],
  "introduction" : "",
  "contactPerson" : {
    "name" : "Ziggy Stardust",
    "email" : null,
    "phone" : null
  },
  "owningSection" : "section",
  "legalBase" : "",
  "publications" : "",
  "derivedFrom" : "",
  "correspondenceTables" : [ ],
  "classificationVariants" : [ ],
  "changelogs" : [ ],
  "levels" : [ {
    "levelNumber" : 1,
    "levelName" : "Nivå 1"
  } ],
  "classificationItems" : [ {
    "code" : "0101",
    "parentCode" : "",
    "level" : "1",
    "name" : "Halden",
    "shortName" : null,
    "notes" : null
  }, {
    "code" : "0104",
    "parentCode" : "",
    "level" : "1",
    "name" : "Moss",
    "shortName" : null,
    "notes" : null
  }, {
    "code" : "0301",
    "parentCode" : "",
    "level" : "1",
    "name" : "Oslo",
    "shortName" : null,
    "notes" : null
  }, {
    "code" : "1739",
    "parentCode" : "",
    "level" : "1",
    "name" : "Røyrvik",
    "shortName" : null,
    "notes" : null
  }, {
    "code" : "1939",
    "parentCode" : "",
    "level" : "1",
    "name" : "Storfjord",
    "shortName" : null,
    "notes" : null
  } ],
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/versions/1"
    }
  }
}

2.6.7. Example request (CSV with ISO-8859-1)

$ curl 'http://data.ssb.no/api/klass/v1/versions/131' -i \
    -H 'Accept: text/csv; charset=ISO-8859-1'

2.6.8. Example response (CSV with ISO-8859-1)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 202

"code";"parentCode";"level";"name";"shortName";"notes";"validFrom";"validTo"
"0101";"";"1";"Halden";;
"0104";"";"1";"Moss";;
"0301";"";"1";"Oslo";;
"1739";"";"1";"Røyrvik";;
"1939";"";"1";"Storfjord";;

2.7. variant

Used to search codes from a classification variant. A range is specified when requesting the codes, and the response will for each code indicate its valid range (validFrom/validTo). The format and character set used, can be specified in the http header. For more information about the range see range.
To get a snapshot of codes valid at a specified date, use variantAt. See also variants

2.7.1. Supported formats

text/csv, application/json, text/xml

2.7.2. Supported character sets

UTF-8, ISO-8859-1 (csv only)

2.7.3. Example request (CSV with UTF-8)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/84/variant?variantName=Klimagasser&from=2020-01-01&to=2021-01-01' -i \
    -H 'Accept: text/csv; charset=UTF-8'

2.7.4. Example response (CSV with UTF-8)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=UTF-8
Content-Length: 481

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange","notes"
"01",,"1","CO2 - karbondioksid","","",,,"2020-01-01","2021-01-01",""
"02",,"1","CH4 - metan","","",,,"2020-01-01","2021-01-01",""
"03",,"1","N2O - lystgass","","",,,"2020-01-01","2021-01-01",""
"04",,"1","Fluorgasser","","",,,"2020-01-01","2021-01-01",""
"04.1",,"2","HFK - hydrofluorkarboner","","",,,"2020-01-01","2021-01-01",""

2.7.5. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1574

{
  "codes" : [ {
    "code" : "01",
    "parentCode" : null,
    "level" : "1",
    "name" : "CO2 - karbondioksid",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  }, {
    "code" : "02",
    "parentCode" : null,
    "level" : "1",
    "name" : "CH4 - metan",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  }, {
    "code" : "03",
    "parentCode" : null,
    "level" : "1",
    "name" : "N2O - lystgass",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  }, {
    "code" : "04",
    "parentCode" : null,
    "level" : "1",
    "name" : "Fluorgasser",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  }, {
    "code" : "04.1",
    "parentCode" : null,
    "level" : "2",
    "name" : "HFK - hydrofluorkarboner",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "validFromInRequestedRange" : "2020-01-01",
    "validToInRequestedRange" : "2021-01-01",
    "notes" : ""
  } ]
}

2.7.6. Request parameters

Parameter Description

variantName

[Mandatory] specifies name of classification variant

NOTE: If you want to look up codes from variants across multiple versions do not include the year (or year month) and do not include everything after that

Example for Particulate matter 2009 - Variant of substances emitted to air 2009 would be Particulate matter

from

[Mandatory] specifies beginning of range with format <yyyy-MM-dd>. For details see range

to

[Optional] specifies end of range with format <yyyy-MM-dd>. If not set means that to is indefinite. For details see range

csvSeparator

[Optional] specifies separator to be used for csv format. For details see csvSeparator

csvFields

[Optional] specifies which fields should be included in the csv output. For details see csvfields

selectCodes

[Optional] only return codes that match pattern given by selectCodes. For details see selectCodes

selectLevel

[Optional] only return codes with matching level. For details see selectLevel

presentationNamePattern

[Optional] used to build a presentationName. For details see presentationNamePattern

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include variants of the future versions if available. Default is false.

2.8. variantAt

Used to search codes from a classification variant. A date is specified when requesting the codes, and the response will include all codes valid at the specified date. The format and character set used, can be specified in the http header.

2.8.1. Supported formats

text/csv, application/json, text/xml

2.8.2. Supported character sets

UTF-8, ISO-8859-1 (csv only)

2.8.3. Example request (CSV with ISO-8859-1)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/84/variantAt?variantName=Klimagasser&date=2015-01-01' -i \
    -H 'Accept: text/csv; charset=ISO-8859-1'

2.8.4. Example response (CSV with ISO-8859-1)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 297

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","notes"
"01",,"1","CO2 - karbondioksid","","",,,""
"02",,"1","CH4 - metan","","",,,""
"03",,"1","N2O - lystgass","","",,,""
"04",,"1","Fluorgasser","","",,,""
"04.1",,"2","HFK - hydrofluorkarboner","","",,,""

2.8.5. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1104

{
  "codes" : [ {
    "code" : "01",
    "parentCode" : null,
    "level" : "1",
    "name" : "CO2 - karbondioksid",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  }, {
    "code" : "02",
    "parentCode" : null,
    "level" : "1",
    "name" : "CH4 - metan",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  }, {
    "code" : "03",
    "parentCode" : null,
    "level" : "1",
    "name" : "N2O - lystgass",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  }, {
    "code" : "04",
    "parentCode" : null,
    "level" : "1",
    "name" : "Fluorgasser",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  }, {
    "code" : "04.1",
    "parentCode" : null,
    "level" : "2",
    "name" : "HFK - hydrofluorkarboner",
    "shortName" : "",
    "presentationName" : "",
    "validFrom" : null,
    "validTo" : null,
    "notes" : ""
  } ]
}

2.8.6. Request parameters

Parameter Description

variantName

[Mandatory] specifies name of classification variant

NOTE: If you want to look up codes from variants across multiple versions do not include the year (or year month) and do not include everything after that

Example for Particulate matter 2009 - Variant of substances emitted to air 2009 would be Particulate matter

date

[Mandatory] specifies codes at a certain date with format <yyyy-MM-dd>.

csvSeparator

[Optional] specifies separator to be used for csv format. For details see csvSeparator

csvFields

[Optional] specifies which fields should be included in the csv output. For details see csvfields

selectCodes

[Optional] only return codes that match pattern given by selectCodes. For details see selectCodes

selectLevel

[Optional] only return codes with matching level. For details see selectLevel

presentationNamePattern

[Optional] used to build a presentationName. For details see presentationNamePattern

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include variants of the future versions if available. Default is false.

2.9. variants by ID

Used to get a classification variant by ID. The ID is shown under versions.

2.9.1. Supported formats

application/json, text/xml, text/csv

2.9.2. Supported character sets

UTF-8, ISO-8859-1 (csv only)

2.9.3. Request parameters

Parameter Description

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

2.9.4. Example request (JSON with UTF-8)

$ curl 'http://data.ssb.no/api/klass/v1/variants/1111' -i \
    -H 'Accept: application/json'

2.9.5. Response structure (JSON, XML)

Path Type Description

name

String

Variant name

contactPerson

Object

Contact information to the SSB section representative

owningSection

String

SSB section number

lastModified

String

Time and date the variant was last time modified at

published

Array

List of languages the version is published in

validFrom

String

Date the variant is valid from

validTo

String

Date the variant is valid to

introduction

String

Variant description

correspondenceTables

Array

List of correspondence tables for the variant

changelogs

Array

Log of changes

levels

Array

List of levels

classificationItems

Array

Array of classification items

_links

Object

Links to operations on the variant

2.9.6. Response structure (JSON, XML)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1454

{
  "name" : "Variant - Tilleggsinndeling for familier 2006  - variant av Gruppering av familier 2006",
  "contactPerson" : {
    "name" : "Ziggy Stardust",
    "email" : null,
    "phone" : null
  },
  "owningSection" : "section",
  "lastModified" : "2022-09-12T13:22:32.807+0000",
  "published" : [ "nb" ],
  "validFrom" : "2006-01-01",
  "validTo" : "2032-01-01",
  "introduction" : "",
  "correspondenceTables" : [ ],
  "changelogs" : [ ],
  "levels" : [ {
    "levelNumber" : 1,
    "levelName" : "Nivå 1"
  }, {
    "levelNumber" : 2,
    "levelName" : "Nivå 2"
  } ],
  "classificationItems" : [ {
    "code" : "A",
    "parentCode" : "",
    "level" : "1",
    "name" : "Enpersonfamilie",
    "shortName" : null,
    "notes" : null
  }, {
    "code" : "A_",
    "parentCode" : "A",
    "level" : "2",
    "name" : "Enpersonfamilie",
    "shortName" : null,
    "notes" : null
  }, {
    "code" : "B",
    "parentCode" : "",
    "level" : "1",
    "name" : "Ektepar",
    "shortName" : null,
    "notes" : null
  }, {
    "code" : "BA",
    "parentCode" : "B",
    "level" : "2",
    "name" : "Ektepar med barn (yngste barn 0-17 år)",
    "shortName" : null,
    "notes" : null
  }, {
    "code" : "BB",
    "parentCode" : "B",
    "level" : "2",
    "name" : "Ektepar uten barn 0-17 år",
    "shortName" : null,
    "notes" : null
  } ],
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/variants/1111"
    }
  }
}

2.9.7. Example request (CSV with ISO-8859-1)

$ curl 'http://data.ssb.no/api/klass/v1/variants/1111' -i \
    -H 'Accept: text/csv; charset=ISO-8859-1'

2.9.8. Example response (CSV with ISO-8859-1)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 263

"code";"parentCode";"level";"name";"shortName";"notes";"validFrom";"validTo"
"A";"";"1";"Enpersonfamilie";;
"A_";"A";"2";"Enpersonfamilie";;
"B";"";"1";"Ektepar";;
"BA";"B";"2";"Ektepar med barn (yngste barn 0-17 år)";;
"BB";"B";"2";"Ektepar uten barn 0-17 år";;

2.10. corresponds

Used to get correspondence mappings between a source classification and a target classification. A range is specified when requesting the correspondence mappings, and the response will for each correspondence map indicate its valid range (validFrom/validTo). For more information about the range see range. If a correspondence table is missing for parts of the range, the API will return 404 (not found). The format and character set used, can be specified in the http header.

To get a snapshot of correspondence mappings valid at a specified date, use correspondsAt

2.10.1. Supported formats

text/csv, application/json, text/xml

2.10.2. Supported character sets

ISO-8859-1 (csv only), UTF-8

2.10.3. Example request (CSV with UTF-8)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/corresponds?targetClassificationId=103&from=2020-01-01&to=2021-01-01' -i \
    -H 'Accept: text/csv; charset=UTF-8'

2.10.4. Example response (CSV with UTF-8)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=UTF-8
Content-Length: 440

"sourceCode","sourceName","sourceShortName","targetCode","targetName","targetShortName","validFrom","validTo"
"0301","Oslo","","030101","Gamle Oslo","","2020-01-01","2021-01-01"
"0301","Oslo","","030103","Sagene","","2020-01-01","2021-01-01"
"0301","Oslo","","030105","Frogner","","2020-01-01","2021-01-01"
"1201","Bergen","","120101","Arna","","2020-01-01","2021-01-01"
"1201","Bergen","","120102","Bergenhus","","2020-01-01","2021-01-01"

2.10.5. Request parameters

Parameter Description

targetClassificationId

[Mandatory] specifies id of target classification

from

[Mandatory] specifies beginning of range with format <yyyy-MM-dd>. For details see range

to

[Optional] specifies end of range with format <yyyy-MM-dd>. If not set means that to is indefinite. For details see range

csvFields

[Optional] specifies which fields should be included in the csv output. For details see csvfields

csvSeparator

[Optional] specifies separator to be used for csv format. For details see csvSeparator

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include future versions if available. Default is false.

2.11. correspondsAt

Used to get correspondence mappings between a source classification and a target classification.

The format and character set used, can be specified in the http header. A date is specified when requesting the correspondence mappings, and the response will include all correspondence mappings valid at the specified date.

2.11.1. Supported formats

text/csv, application/json, text/xml

2.11.2. Supported character sets

ISO-8859-1 (csv only), UTF-8

2.11.3. Example request (CSV with UTF-8)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/correspondsAt?targetClassificationId=103&date=2018-01-01' -i \
    -H 'Accept: text/csv; charset=UTF-8'

2.11.4. Example response (CSV with UTF-8)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=UTF-8
Content-Length: 288

"sourceCode","sourceName","sourceShortName","targetCode","targetName","targetShortName"
"0301","Oslo","","030101","Gamle Oslo",""
"0301","Oslo","","030103","Sagene",""
"0301","Oslo","","030105","Frogner",""
"1201","Bergen","","120101","Arna",""
"1201","Bergen","","120102","Bergenhus",""

2.11.5. Request parameters

Parameter Description

targetClassificationId

[Mandatory] specifies id of target classification

date

[Mandatory] specifies codes at a certain date with format <yyyy-MM-dd>.

csvSeparator

[Optional] specifies separator to be used for csv format. For details see csvSeparator

csvFields

[Optional] specifies which fields should be included in the csv output. For details see csvfields

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include future versions if available. Default is false.

2.12. correspondenceTables by ID

Used to get an existent correspondence table by its ID specified in the URL. To navigate to the target or the source classification version use links specified in the JSON or XML response. The ID is shown under versions by ID. This method can also be used within versions of the same classification.

2.12.1. Supported formats

text/csv, application/json, text/xml

2.12.2. Supported character sets

ISO-8859-1 (csv only), UTF-8

2.12.3. Example request (CSV with ISO-8859-1)

$ curl 'http://data.ssb.no/api/klass/v1/correspondencetables/1' -i \
    -H 'Accept: text/csv; charset=ISO-8859-1'

2.12.4. Example response (CSV with ISO-8859-1)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 78

"sourceCode";"sourceName";"targetCode";"targetName"
"01";"Oslo";"0301";"Oslo"

2.12.5. Example request (JSON with UTF-8)

$ curl 'http://data.ssb.no/api/klass/v1/correspondencetables/1' -i \
    -H 'Accept: application/json'

2.12.6. Response structure (JSON, XML)

Path Type Description

name

String

Correspondence table’s name

contactPerson

Object

Contact information to the SSB section representative

owningSection

String

SSB section number

source

String

Name to the source classification version

sourceId

Number

ID to the source classification version

target

String

Name to the target classification version

targetId

Number

ID to the target classification version

changeTable

Boolean

Changes done to the table

lastModified

String

Timestamp for the last modifications done to the table

published

Array

A list of the languages the correspondence table is published in

sourceLevel

Null

Level name and number for the source classification version

targetLevel

Null

Level name and number for the target classification version

description

String

Description

changelogs

Array

A list of the changes done to the correspondence table

correspondenceMaps

Array

A list of the mappings the correspondence table includes

_links

Object

links to operations on classificationFamily

2.12.7. Example response (JSON with UTF-8)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 985

{
  "name" : "Arbeidsgiveravgiftssoner 2012 - Kommuneinndeling 2012",
  "contactPerson" : {
    "name" : "Ziggy Stardust",
    "email" : null,
    "phone" : null
  },
  "owningSection" : "section",
  "source" : "Arbeidsgiveravgiftssoner 2012",
  "sourceId" : 2,
  "target" : "Kommuneinndeling 2012",
  "targetId" : 7,
  "changeTable" : false,
  "lastModified" : "2022-09-12T13:22:31.210+0000",
  "published" : [ "nb" ],
  "sourceLevel" : null,
  "targetLevel" : null,
  "description" : "Mapping Arbeidsgiveravgiftssoner - Kommuneinndeling",
  "changelogs" : [ ],
  "correspondenceMaps" : [ {
    "sourceCode" : "01",
    "sourceName" : "Oslo",
    "targetCode" : "0301",
    "targetName" : "Oslo"
  } ],
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/correspondencetables/1"
    },
    "source" : {
      "href" : "http://data.ssb.no/api/klass/v1/versions/2"
    },
    "target" : {
      "href" : "http://data.ssb.no/api/klass/v1/versions/7"
    }
  }
}
Relation Description

self

The current request

source

Table’s source classification version

target

Table’s target classification version

2.12.9. Request parameters

Parameter Description

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

2.13. changes

List codes that have changed within a time range. The format and character set used, can be specified in the http header (character set is only available for CSV).

  • If no oldCode is present it means that newCode started to exist at time given by changeOccurred.

  • If no newCode is present it means that oldCode ceased to exist at time given by changeOccurred.

2.13.1. Supported formats

text/csv, application/json, text/xml

2.13.2. Supported character sets

ISO-8859-1 (csv only), UTF-8

2.13.3. Example request (CSV with ISO-8859-1)

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/changes?from=2020-01-01&to=2021-01-01' -i \
    -H 'Accept: text/csv'

2.13.4. Example response (CSV with ISO-8859-1)

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 87

"oldCode","oldName","oldShortName","newCode","newName","newShortName","changeOccurred"

2.13.5. Request parameters

Parameter Description

from

[Mandatory] specifies beginning of range with format <yyyy-MM-dd>. For details see range

to

[Optional] specifies end of range with format <yyyy-MM-dd>. If not set means that to is indefinite. For details see range

csvSeparator

[Optional] specifies separator to be used for csv format. For details see csvSeparator

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

includeFuture

[Optional] include future versions if available. Default is false.

2.14. classificationfamilies

Classification family is a grouping of classifications, used on the opening page of the Klass application.

2.14.1. Supported formats

application/json, text/xml

2.14.2. Example request (JSON)

$ curl 'http://data.ssb.no/api/klass/v1/classificationfamilies' -i \
    -H 'Accept: application/json'

2.14.3. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 381

{
  "_embedded" : {
    "classificationFamilies" : [ {
      "name" : "Befolkning",
      "numberOfClassifications" : 1,
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classificationfamilies/3"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/classificationfamilies"
    }
  }
}

2.14.4. Response structure

Path Type Description

_embedded.classificationFamilies

Array

An array of ClassificationFamilies

_embedded.classificationFamilies[].name

String

ClassificationFamily name

_embedded.classificationFamilies[].numberOfClassifications

Number

Number of classifications belonging to classificationFamily

_embedded.classificationFamilies[]._links

Object

Link to classificationFamily

_links

Object

Links to other resources

Relation Description

self

The current request

2.14.6. Request parameters

Parameter Description

ssbSection

[Optional] only include classifications belonging to specified SSB section when counting number of classifications. Default is all SSB sections

includeCodelists

[Optional] include codelists when counting number of classifications. Default is false

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

2.15. classificationfamilies by ID

Get details of a classification family, used on the opening page of the Klass application.

2.15.1. Supported formats

application/json, text/xml

2.15.2. Example request (JSON)

$ curl 'http://data.ssb.no/api/klass/v1/classificationfamilies/3' -i \
    -H 'Accept: application/json'

2.15.3. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 438

{
  "name" : "Befolkning",
  "classifications" : [ {
    "name" : "Standard for kommuneinndeling",
    "classificationType" : "Klassifikasjon",
    "lastModified" : "2022-09-12T13:22:32.908+0000",
    "_links" : {
      "self" : {
        "href" : "http://data.ssb.no/api/klass/v1/classifications/131"
      }
    }
  } ],
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/classificationfamilies/3"
    }
  }
}

2.15.4. Response structure

Path Type Description

name

String

ClassificationFamily name

classifications

Array

Array of classifications

_links

Object

Links to operations on classificationFamily

Relation Description

self

The current request

2.15.6. Request parameters

Parameter Description

ssbSection

[Optional] only include classifications belonging to specified SSB section when listing classifications. Default is all SSB sections

includeCodelists

[Optional] include codelists when listing classifications. Default is false

language

[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language

2.16. ssbsections

List Statistics Norway divisions responsible for at least one classification.

2.16.1. Supported formats

application/json, text/xml

2.16.2. Example request (JSON)

$ curl 'http://data.ssb.no/api/klass/v1/ssbsections' -i \
    -H 'Accept: application/json'

2.16.3. Example response (JSON)

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 220

{
  "_embedded" : {
    "ssbSections" : [ {
      "name" : "Seksjon for primærnæringsstatistikk (420)"
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/ssbsections"
    }
  }
}

2.16.4. Response structure

Path Type Description

_embedded.ssbSections

Array

Array of ssb sections

_embedded.ssbSections[].name

String

Name of ssb section

_links

Object

Links to operations on ssb sections

Relation Description

self

The current request

3. Request parameters

3.1. range

A range is a time period with a from date and a to date. The dates are specified in format <yyyy-mm-dd>. from is inclusive and to is exclusive. to is optional, and if not specified the end of the range is considered to be indefinite.

When retrieving codes with a range the code may change during the range. This is indicated in the result with validFrom and validTo.

3.1.1. Example

A classification whose codes were updated 2014-01-01. If asking for codes for year 2013, then validFrom/validTo in response will be equal to from/to in request

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2019-01-01&to=2020-01-01' -i \
    -H 'Accept: text/csv'
HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 442

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange","notes"
"0101",,"1","Halden","","",,,"2019-01-01","2020-01-01",""
"0104",,"1","Moss","","",,,"2019-01-01","2020-01-01",""
"1515",,"1","Herøy","","",,,"2019-01-01","2020-01-01",""
"1825",,"1","Grane","","",,,"2019-01-01","2020-01-01",""
"1826",,"1","Hattfjelldal","","",,,"2019-01-01","2020-01-01",""

If now increasing the range to also include 2014, it is seen that some codes are not valid within the whole range. Some codes end at 2014 and some codes start in 2014.

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2019-01-01&to=2021-01-01' -i \
    -H 'Accept: text/csv'
HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 706

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange","notes"
"0101",,"1","Halden","","",,,"2019-01-01","2020-01-01",""
"0104",,"1","Moss","","",,,"2019-01-01","2020-01-01",""
"1515",,"1","Herøy","","",,,"2019-01-01","2020-01-01",""
"1515",,"1","Herøy (Møre og Romsdal)","","",,,"2020-01-01","2021-01-01",""
"1825",,"1","Grane","","",,,"2019-01-01","2021-01-01",""
"1826",,"1","Hattfjelldal","","",,,"2019-01-01","2020-01-01",""
"1826",,"1","Aarborte - Hattfjelldal","","",,,"2020-01-01","2021-01-01",""
"3001",,"1","Halden","","",,,"2020-01-01","2021-01-01",""
"3002",,"1","Moss","","",,,"2020-01-01","2021-01-01",""

3.2. changedSince

changedSince is used to find classifications that have been updated since a specified time. changedSince is specified in ISO 8601 DateTime format <yyyy-MM-dd’T’HH:mm:ss.SSSZ> e.g. "2015-10-31T01:30:00.000-0200"

3.2.1. Example

$ curl 'http://data.ssb.no/api/klass/v1/classifications?changedSince=2015-03-01T01:30:00.000-0200' -i \
    -H 'Accept: application/json'

3.3. selectCodes

selectCodes is used to limit the result to codes that match the pattern given by selectCodes.
selectCodes is a comma separated list of codes (may also use wildcard ' * ')
selectCodes can also contain ranges of codes, a range is defined using '-' between 2 codes (Wildcard '*' can also be used in range).

Codes selected

selectCodes = 3004

Only 3004

selectCodes = 3004, 3006

Only 3004 and 3006

selectCodes = 3004, 11*

3004 and all starting with 11

selectCodes = 3004-3400

range from 3004 to 3400

selectCodes = 3004-34*

range from 3004 to any higher code starting with 34

3.3.1. Example request for selectCodes=0301,01*;

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2020-01-01&to=2021-01-01&selectCodes=3415-3418,300*' -i \
    -H 'Accept: text/csv'

3.3.2. Example response

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 801

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange","notes"
"3001",,"1","Halden","","",,,"2020-01-01","2021-01-01",""
"3002",,"1","Moss","","",,,"2020-01-01","2021-01-01",""
"3003",,"1","Sarpsborg","","",,,"2020-01-01","2021-01-01",""
"3004",,"1","Fredrikstad","","",,,"2020-01-01","2021-01-01",""
"3005",,"1","Drammen","","",,,"2020-01-01","2021-01-01",""
"3006",,"1","Kongsberg","","",,,"2020-01-01","2021-01-01",""
"3007",,"1","Ringerike","","",,,"2020-01-01","2021-01-01",""
"3415",,"1","Sør-Odal","","",,,"2020-01-01","2021-01-01",""
"3416",,"1","Eidskog","","",,,"2020-01-01","2021-01-01",""
"3417",,"1","Grue","","",,,"2020-01-01","2021-01-01",""
"3418",,"1","Åsnes","","",,,"2020-01-01","2021-01-01",""

3.4. csvSeparator

csvSeparator is used to specify a separator symbol to be used for csv format. Default is ,

3.4.1. Example request for csvSeparator=;

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2020-01-01&to=2021-01-01&csvSeparator=;' -i \
    -H 'Accept: text/csv'

3.4.2. Example response

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 388

"code";"parentCode";"level";"name";"shortName";"presentationName";"validFrom";"validTo";"validFromInRequestedRange";"validToInRequestedRange";"notes"
"3001";;"1";"Halden";"";"";;;"2020-01-01";"2021-01-01";""
"3002";;"1";"Moss";"";"";;;"2020-01-01";"2021-01-01";""
"3003";;"1";"Sarpsborg";"";"";;;"2020-01-01";"2021-01-01";""
"3004";;"1";"Fredrikstad";"";"";;;"2020-01-01";"2021-01-01";""

3.5. csvFields

csvFields is an optional parameter that allows a user to filter columns and specify columns order in the Csv output. It is applicable for /codes, /codesAt, /variantAt, /correspondsAt services.

The field names are case-sensitive. Misspelled field names will cause a 400 Bad Request error.

3.5.1. Example request for csvFields=name,code with /codesAt;

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codesAt?date=2020-01-01&csvSeparator=;&csvFields=name,code' -i \
    -H 'Accept: text/csv'

3.5.2. Example response

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 84

"name";"code"
"Halden";"3001"
"Moss";"3002"
"Sarpsborg";"3003"
"Fredrikstad";"3004"

3.6. language

language is used to specify a language data shall be presented in. If none selected, the default is "nb" (Norwegian Bokmål).

Supported languages

Language code

Language

nb

Norwegian Bokmål

nn

Norwegian Nynorsk

en

English

3.6.1. Example request for language=nb

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2015-01-01&to=2016-01-01&language=nb' -i \
    -H 'Accept: text/csv'

3.6.2. Example response

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 388

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange","notes"
"3001",,"1","Halden","","",,,"2015-01-01","2016-01-01",""
"3002",,"1","Moss","","",,,"2015-01-01","2016-01-01",""
"3003",,"1","Sarpsborg","","",,,"2015-01-01","2016-01-01",""
"3004",,"1","Fredrikstad","","",,,"2015-01-01","2016-01-01",""

3.7. selectLevel

selectLevel is used to limit result to codes that are at specified level

3.7.1. Example request for selectLevel=1

$ curl 'http://data.ssb.no/api/klass/v1/classifications/17/codes?from=2020-01-01&to=2021-01-01&selectLevel=2' -i \
    -H 'Accept: text/csv'

3.7.2. Example response

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 378

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange","notes"
"A_",,"2","Enpersonfamilie","","",,,"2020-01-01","2021-01-01",""
"BA",,"2","Ektepar med barn (yngste barn 0-17 år)","","",,,"2020-01-01","2021-01-01",""
"BB",,"2","Ektepar uten barn 0-17 år","","",,,"2020-01-01","2021-01-01",""

3.8. presentationNamePattern

presentationNamePattern is used to build an alternative presentationName. To build a presentationName use curly braces to access other columns:

{code}
{name}
{shortName}
{lowercase(code/name/shortname)}
{uppercase(code/name/shortname)}
{capitalize(code/name/shortname)}

3.8.1. Examples

Given that:
code = 0101
name = Halden

presentationNamePattern presentationName

{code} - {name}

0101 - Halden

{code} - {lowercase(name)}

0101 - halden

{code} - {capitalize(name)}

0101 - Halden

{code} - {uppercase(name)}

0101 - HALDEN

{name} {code}

Halden 0101

3.8.2. Example request for presentationNamePattern={code}-{uppercase(name)}

(In request due to url encoding %7B = { , and %7D = })

$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2020-01-01&to=2021-01-01&presentationNamePattern=%7Bcode%7D-%7Buppercase(name)%7D' -i \
    -H 'Accept: text/csv'

3.8.3. Example response

HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 438

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange","notes"
"3001",,"1","Halden","","3001-HALDEN",,,"2020-01-01","2021-01-01",""
"3002",,"1","Moss","","3002-MOSS",,,"2020-01-01","2021-01-01",""
"3003",,"1","Sarpsborg","","3003-SARPSBORG",,,"2020-01-01","2021-01-01",""
"3004",,"1","Fredrikstad","","3004-FREDRIKSTAD",,,"2020-01-01","2021-01-01",""

3.9. ssbSection

ssbSection is used to limit result to classifications belonging to specified SSB division when searching classifications. Default is all SSB divisions.

3.9.1. Example request for ssbSection

$ curl 'http://data.ssb.no/api/klass/v1/classifications/search?query=kommuner&includeCodelists=true&ssbSection=370' -i \
    -H 'Accept: application/json'

3.9.2. Example response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 606

{
  "_embedded" : {
    "searchResults" : [ {
      "name" : "Standard for kommuneinndeling",
      "snippet" : "Kommuneinndelingen er en administrativ inndeling av Norge",
      "searchScore" : 8.0,
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/131"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/search?query=kommuner&includeCodelists=true&ssbSection=370"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 1,
    "totalPages" : 1,
    "number" : 0
  }
}

4. Other

4.1. page

When the response contains a collection of resources (e.g. classifications or searchResults), the response will limit the returned collection to a page of configurable size. It is possible to set the size of the page in the request.

4.1.1. Example request

$ curl 'http://data.ssb.no/api/klass/v1/classifications?size=2' -i \
    -H 'Accept: application/json'

4.1.2. Example response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1289

{
  "_embedded" : {
    "classifications" : [ {
      "name" : "Standard for kommuneinndeling",
      "classificationType" : "Klassifikasjon",
      "lastModified" : "2022-09-12T13:22:33.036+0000",
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/131"
        }
      }
    }, {
      "name" : "Standard for bydelsinndeling",
      "classificationType" : "Klassifikasjon",
      "lastModified" : "2022-09-12T13:22:33.036+0000",
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/103"
        }
      }
    } ]
  },
  "_links" : {
    "first" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications?page=0&size=2"
    },
    "self" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications?size=2"
    },
    "next" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications?page=1&size=2"
    },
    "last" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications?page=1&size=2"
    },
    "search" : {
      "href" : "http://data.ssb.no/api/klass/v1/classifications/search{?query,includeCodelists}",
      "templated" : true
    }
  },
  "page" : {
    "size" : 2,
    "totalElements" : 3,
    "totalPages" : 2,
    "number" : 0
  }
}

4.1.3. Response structure

Path Type Description

page.size

Number

Size of a page (number of elements per page)

page.totalElements

Number

Total number of elements in collection

page.totalPages

Number

Total number of pages

page.number

Number

Page number

Relation Description

self

The current request

search

Search

first

First page

next

Next page

last

Last page