1. Overview

1.1. Rest Client

Examples in this documentation uses curl. If this tool is unknown an alternative is to use a Rest client to explore Klass Rest interface, see instructions Rest client guide.

1.2. URL Encoding

The current version of 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 malformed, i.e. the client has used a not valid request. The response body will include an error providing further information

404 Not Found

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

1.4. Errors

Whenever an error response (status code >= 400) is returned, the body 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

2. Classification Resources

2.1. List classifications

List classifications in Klass

Supported formats

application/json, text/xml

Example request (json)
$ curl 'http://data.ssb.no/api/klass/v1/classifications' -i \
    -H 'Accept: application/json'
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" : "2017-11-06T13:10:36.221+0000",
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/131"
        }
      }
    }, {
      "name" : "Standard for bydelsinndeling",
      "classificationType" : "Klassifikasjon",
      "lastModified" : "2017-11-06T13:10:36.221+0000",
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/103"
        }
      }
    }, {
      "name" : "Standard for gruppering av familier",
      "classificationType" : "Klassifikasjon",
      "lastModified" : "2017-11-06T13:10:36.221+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
  }
}
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

Request parameters
Parameter Description

includeCodelists

[Optional] include ssb internal classifications, also referred to as codelists. Default is false

changedSince

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

Search classifications in Klass

Supported formats

application/json, text/xml

Example request (json)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/search?query=kommuner' -i \
    -H 'Accept: application/json'
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
  }
}
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

Request parameters
Parameter Description

query

[Mandatory] specifies search terms

includeCodelists

[Optional] include ssb internal classifications, also referred to as codelists. Default is false

ssbSection

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

2.3. Classification

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

Supported formats

application/json
text/xml

Example request (json)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/131' -i \
    -H 'Accept: application/json'
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" : "2017-11-06T13:10:32.581+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" : "2017-11-06T13:10:32.581+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" : "2017-11-06T13:10:32.581+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
    }
  }
}
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

Request parameters
Parameter Description

language

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

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). The format and character set used, must be set in the http header (setting character set is only available for csv). For more information about the range see range.
To get a snapshot of codes valid at a specified date, use CodesAt

Supported formats

text/csv, application/json, text/xml

Supported character sets (csv only)

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

Example request (csv with UTF-8)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2014-01-01&to=2015-01-01' -i \
    -H 'Accept: text/csv; charset=UTF-8'
Example response (csv with UTF-8)
HTTP/1.1 200 OK
Content-Type: text/csv;charset=UTF-8
Content-Length: 368

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange"
"0101",,"1","Halden","","",,,"2014-01-01","2015-01-01"
"0104",,"1","Moss","","",,,"2014-01-01","2015-01-01"
"0105",,"1","Sarpsborg","","",,,"2014-01-01","2015-01-01"
"0106",,"1","Fredrikstad","","",,,"2014-01-01","2015-01-01"
Request parameters
Parameter Description

from

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

to

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

csvSeparator

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

selectCodes

[Optional] only return codes that matches 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 (bokmål). For details see language

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, must be set in the http header (setting character set is only available for csv).

Supported formats

text/csv, application/json, text/xml

Supported character sets (csv only)

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

Example request (csv with ISO-8859-1)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codesAt?date=2015-01-01' -i \
    -H 'Accept: text/csv; charset=ISO-8859-1'
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","presentationName","validFrom","validTo"
"0101",,"1","Halden","",""
"0104",,"1","Moss","",""
"0105",,"1","Sarpsborg","",""
"0106",,"1","Fredrikstad","",""
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

selectCodes

[Optional] only return codes that matches 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 (bokmål). For details see language

2.6. Variant

Used to get 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, must be set in the http header (setting character set is only available for csv). For more information about the range see range.
To get a snapshot of codes valid at a specified date, use VariantAt

Supported formats

text/csv, application/json, text/xml

Supported character sets (csv only)

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

Example request (csv with UTF-8)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/17/variant?variantName=Tilleggsinndeling%20for%20familier&from=2014-01-01&to=2015-01-01' -i \
    -H 'Accept: text/csv; charset=UTF-8'
Example response (csv with UTF-8)
HTTP/1.1 200 OK
Content-Type: text/csv;charset=UTF-8
Content-Length: 477

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange"
"A",,"1","Enpersonfamilie","","",,,"2014-01-01","2015-01-01"
"A_",,"2","Enpersonfamilie","","",,,"2014-01-01","2015-01-01"
"B",,"1","Ektepar","","",,,"2014-01-01","2015-01-01"
"BA",,"2","Ektepar med barn (yngste barn 0-17 år)","","",,,"2014-01-01","2015-01-01"
"BB",,"2","Ektepar uten barn 0-17 år","","",,,"2014-01-01","2015-01-01"
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

Ex. 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] spesifies end of range with format <yyyy-MM-dd>. If not set means that to is indefinately. For details see range

csvSeparator

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

selectCodes

[Optional] only return codes that matches 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 (bokmål). For details see language

2.7. VariantAt

Used to get 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, must be set in the http header (setting character set is only available for csv).

Supported formats

text/csv, application/json, text/xml

Supported character sets (csv only)

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

Example request (csv with ISO-8859-1)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/17/variantAt?variantName=Variant%20-%20Tilleggsinndeling%20for%20familier&date=2015-01-01' -i \
    -H 'Accept: text/csv; charset=ISO-8859-1'
Example response (csv with ISO-8859-1)
HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 281

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo"
"A",,"1","Enpersonfamilie","",""
"A_",,"2","Enpersonfamilie","",""
"B",,"1","Ektepar","",""
"BA",,"2","Ektepar med barn (yngste barn 0-17 år)","",""
"BB",,"2","Ektepar uten barn 0-17 år","",""
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

Ex. 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

selectCodes

[Optional] only return codes that matches 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 (bokmål). For details see language

2.8. Corresponds

Used to get correspondence mappings between a source classification and a target classification. Corresponds works only in the direction the correspondence table is made. A switch of source and target, returns 404 (no correspondence table). A range is specified when requesting the correspondence mappings, and the response will for each correspondence map indicate its valid range (validFrom/validTo). If a correspondence table is missing for parts of the range, the API will return 404 (not found). The format and character set used, must be set in the http header (setting character set is only available for csv). For more information about the range see range.
To get a snapshot of correspondence mappings valid at a specified date, use CorrespondsAt

Supported formats

text/csv, application/json, text/xml

Supported character sets (csv only)

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

Example request (csv with UTF-8)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/corresponds?targetClassificationId=103&from=2014-01-01&to=2015-01-01' -i \
    -H 'Accept: text/csv; charset=UTF-8'
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","","2014-01-01","2015-01-01"
"0301","Oslo","","030103","Sagene","","2014-01-01","2015-01-01"
"0301","Oslo","","030105","Frogner","","2014-01-01","2015-01-01"
"1201","Bergen","","120101","Arna","","2014-01-01","2015-01-01"
"1201","Bergen","","120102","Bergenhus","","2014-01-01","2015-01-01"
Request parameters
Parameter Description

targetClassificationId

[Mandatory] specifies id of corresponding classification

from

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

to

[Optional] spesifies end of range with format <yyyy-MM-dd>. If not set means that to is indefinately. 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 (bokmål). For details see language

2.9. CorrespondsAt

Used to get correspondence mappings between a source classification and a target classification. CorrespondsAt works only in the direction the correspondence table is made. A switch of source and target, returns 404 (no correspondence table). The format and character set used, must be set in the http header (setting character set is only available for csv). A date is specified when requesting the correspondence mappings, and the response will include all correspondence mappings valid at the specified date.

Supported formats

text/csv, application/json, text/xml

Supported character sets (csv only)

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

Example request (csv with UTF-8)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/correspondsAt?targetClassificationId=103&date=2014-01-01' -i \
    -H 'Accept: text/csv; charset=UTF-8'
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",""
Request parameters
Parameter Description

targetClassificationId

[Mandatory] specifies id of corresponding 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

language

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

2.10. Changes

List codes that has changed within a time range. The format and character set used, must be set in the http header (setting 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.

Supported formats

text/csv, application/json, text/xml

Supported character sets (csv only)

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

Example request (csv with ISO-8859-1)
$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/changes?from=2014-01-01&to=2015-01-01' -i \
    -H 'Accept: text/csv'
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"
Request parameters
Parameter Description

from

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

to

[Optional] spesifies end of range with format <yyyy-MM-dd>. If not set means that to is indefinately. 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 (bokmål). For details see language

2.11. List classificationFamilies

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

Supported formats

application/json, text/xml

Example request (json)
$ curl 'http://data.ssb.no/api/klass/v1/classificationfamilies' -i \
    -H 'Accept: application/json'
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"
    }
  }
}
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

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 (bokmål). For details see language

2.12. ClassificationFamily

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

Supported formats

application/json
text/xml

Example request (json)
$ curl 'http://data.ssb.no/api/klass/v1/classificationfamilies/3' -i \
    -H 'Accept: application/json'
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" : "2017-11-06T13:10:36.840+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"
    }
  }
}
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

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 (bokmål). For details see language

2.13. List ssbSections

List Statistics Norway divisions that are responsible for at least one classification.

Supported formats

application/json, text/xml

Example request (json)
$ curl 'http://data.ssb.no/api/klass/v1/ssbsections' -i \
    -H 'Accept: application/json'
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"
    }
  }
}
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 range is considered to continue indefinitely.

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

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 from/to in request

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

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange"
"0101",,"1","Halden","","",,,"2013-01-01","2014-01-01"
"0104",,"1","Moss","","",,,"2013-01-01","2014-01-01"
"1739",,"1","Røyrvik","","",,,"2013-01-01","2014-01-01"
"1939",,"1","Storfjord","","",,,"2013-01-01","2014-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 ends at 2014 and some codes starts at 2014.

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

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange"
"0101",,"1","Halden","","",,,"2013-01-01","2015-01-01"
"0104",,"1","Moss","","",,,"2013-01-01","2015-01-01"
"1739",,"1","Raarvihke Røyrvik","","",,,"2014-01-01","2015-01-01"
"1739",,"1","Røyrvik","","",,,"2013-01-01","2014-01-01"
"1939",,"1","Omasvuotna Storfjord Omasvuonon","","",,,"2014-01-01","2015-01-01"
"1939",,"1","Storfjord","","",,,"2013-01-01","2014-01-01"

3.2. changedSince

changedSince is used to find classifications that has 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

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 result to codes that matches 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 = 0104

Only 0104

selectCodes = 0104, 0106

Only 0104 and 0106

selectCodes = 0104, 02*

0104 and all starting with 02

selectCodes = 0104-0200

range from 0104 to 0200

selectCodes = 0104-02*

range from 0104 to any higher code starting with 02

Example request for selectCodes=0301,01*;
$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2015-01-01&to=2016-01-01&selectCodes=0301-0305,01*' -i \
    -H 'Accept: text/csv'
Example response
HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 474

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange"
"0101",,"1","Halden","","",,,"2015-01-01","2016-01-01"
"0104",,"1","Moss","","",,,"2015-01-01","2016-01-01"
"0105",,"1","Sarpsborg","","",,,"2015-01-01","2016-01-01"
"0106",,"1","Fredrikstad","","",,,"2015-01-01","2016-01-01"
"0301",,"1","Oslo","","",,,"2015-01-01","2016-01-01"
"0304",,"1","Oslo","","",,,"2015-01-01","2016-01-01"

3.4. csvSeparator

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

Example request for csvSeparator=;
$ curl 'http://data.ssb.no/api/klass/v1/classifications/131/codes?from=2014-01-01&to=2015-01-01&csvSeparator=;' -i \
    -H 'Accept: text/csv'
Example response
HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 368

"code";"parentCode";"level";"name";"shortName";"presentationName";"validFrom";"validTo";"validFromInRequestedRange";"validToInRequestedRange"
"0101";;"1";"Halden";"";"";;;"2014-01-01";"2015-01-01"
"0104";;"1";"Moss";"";"";;;"2014-01-01";"2015-01-01"
"0105";;"1";"Sarpsborg";"";"";;;"2014-01-01";"2015-01-01"
"0106";;"1";"Fredrikstad";"";"";;;"2014-01-01";"2015-01-01"

3.5. language

language is used to specify which language data shall be presented in. Default if none is selected is NB (bokmål).

Supported languages

Language code

Language

nb

Norwegian bokmål

nn

Norwegian nynorsk

en

English

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'
Example response
HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 368

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange"
"0101",,"1","Halden","","",,,"2015-01-01","2016-01-01"
"0104",,"1","Moss","","",,,"2015-01-01","2016-01-01"
"0105",,"1","Sarpsborg","","",,,"2015-01-01","2016-01-01"
"0106",,"1","Fredrikstad","","",,,"2015-01-01","2016-01-01"

3.6. selectLevel

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

Example request for selectLevel=1
$ curl 'http://data.ssb.no/api/klass/v1/classifications/17/codes?from=2014-01-01&to=2015-01-01&selectLevel=2' -i \
    -H 'Accept: text/csv'
Example response
HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 361

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

3.7. 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)}

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

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=2014-01-01&to=2015-01-01&presentationNamePattern=%7Bcode%7D-%7Buppercase(name)%7D' -i \
    -H 'Accept: text/csv'
Example response
HTTP/1.1 200 OK
Content-Type: text/csv;charset=ISO-8859-1
Content-Length: 418

"code","parentCode","level","name","shortName","presentationName","validFrom","validTo","validFromInRequestedRange","validToInRequestedRange"
"0101",,"1","Halden","","0101-HALDEN",,,"2014-01-01","2015-01-01"
"0104",,"1","Moss","","0104-MOSS",,,"2014-01-01","2015-01-01"
"0105",,"1","Sarpsborg","","0105-SARPSBORG",,,"2014-01-01","2015-01-01"
"0106",,"1","Fredrikstad","","0106-FREDRIKSTAD",,,"2014-01-01","2015-01-01"

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. The size of the page is possible to set in the request.

Example request
$ curl 'http://data.ssb.no/api/klass/v1/classifications?size=2' -i \
    -H 'Accept: application/json'
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" : "2017-11-06T13:10:37.828+0000",
      "_links" : {
        "self" : {
          "href" : "http://data.ssb.no/api/klass/v1/classifications/131"
        }
      }
    }, {
      "name" : "Standard for bydelsinndeling",
      "classificationType" : "Klassifikasjon",
      "lastModified" : "2017-11-06T13:10:37.828+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
  }
}
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