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 |
---|---|
|
The request completed successfully |
|
The request was badly formed, i.e. the client has used an invalid request. The response will include an error providing further information |
|
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 'https://data.ssb.no/api/klass/v1/classifications/99999' -i -X GET
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: https://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 'https://data.ssb.no/api/klass/v1/classifications' -i -X GET \
-H 'Accept: application/json'
2.1.3. Example response (JSON)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1370
{
"_embedded" : {
"classifications" : [ {
"name" : "Standard for kommuneinndeling",
"id" : 131,
"classificationType" : "Klassifikasjon",
"lastModified" : "2024-06-26T11:35:20.498+0000",
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131"
}
}
}, {
"name" : "Standard for bydelsinndeling",
"id" : 103,
"classificationType" : "Klassifikasjon",
"lastModified" : "2024-06-26T11:35:20.498+0000",
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/103"
}
}
}, {
"name" : "Standard for gruppering av familier",
"id" : 17,
"classificationType" : "Klassifikasjon",
"lastModified" : "2024-06-26T11:35:20.498+0000",
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/17"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/v1/classifications"
},
"search" : {
"href" : "https://data.ssb.no/api/klass/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 |
---|---|---|
|
|
An array of Classifications |
|
|
Classification name |
|
|
Last modification time of classification |
|
|
Link to classification |
|
|
Links to other resources |
|
|
Describes number of classifications returned, see page |
2.1.5. Links
Relation | Description |
---|---|
|
The current request |
|
Link to search for classifications |
2.1.6. Request parameters
Parameter | Description |
---|---|
|
[Optional] include ssb codelists. Default is false. |
|
[Optional] specifies that only classifications that have been changed since changedSince shall be included in the response. For details see changedSince |
2.2. Search for classifications
Search for classifications in Klass
2.2.1. Supported formats
application/json
, text/xml
2.2.2. Example request (JSON)
$ curl 'https://data.ssb.no/api/klass/v1/classifications/search?query=kommuner' -i -X GET \
-H 'Accept: application/json'
2.2.3. Example response (JSON)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 598
{
"_embedded" : {
"searchResults" : [ {
"name" : "Standard for kommuneinndeling",
"id" : 131,
"snippet" : "Kommuneinndelingen er en administrativ inndeling av Norge",
"searchScore" : 8.0,
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/v1/classifications/search?query=kommuner"
}
},
"page" : {
"size" : 1,
"totalElements" : 1,
"totalPages" : 1,
"number" : 0
}
}
2.2.4. Response structure
Path | Type | Description |
---|---|---|
|
|
An array of search results |
|
|
A line containing match for the words searched |
|
|
Represents this classifications relevans for the search |
|
|
Link to classification that matched search |
|
|
Links to other resources |
|
|
Describes number of classifications returned, see page |
2.2.5. Links
Relation | Description |
---|---|
|
The current search |
2.2.6. Request parameters
Parameter | Description |
---|---|
|
[Mandatory] specifies search terms |
|
[Optional] include ssb codelists. Default is false. |
|
[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 'https://data.ssb.no/api/klass/v1/classifications/131' -i -X GET \
-H 'Accept: application/json'
2.3.3. Example response (JSON)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 2791
{
"name" : "Standard for kommuneinndeling",
"id" : 131,
"classificationType" : "Klassifikasjon",
"lastModified" : "2024-06-26T11:35:19.887+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",
"id" : 1,
"validFrom" : "2014-01-01",
"lastModified" : "2024-06-26T11:35:19.887+0000",
"published" : [ "nb" ],
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/versions/1"
}
}
}, {
"name" : "Kommuneinndeling 2012",
"id" : 1,
"validFrom" : "2012-01-01",
"validTo" : "2014-01-01",
"lastModified" : "2024-06-26T11:35:19.891+0000",
"published" : [ "nb" ],
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/versions/1"
}
}
} ],
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131"
},
"codes" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131/codes{?from=<yyyy-MM-dd>,to=<yyyy-MM-dd>,csvSeparator,level,selectCodes,presentationNamePattern}",
"templated" : true
},
"codesAt" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131/codesAt{?date=<yyyy-MM-dd>,csvSeparator,level,selectCodes,presentationNamePattern}",
"templated" : true
},
"variant" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131/variant{?variantName,from=<yyyy-MM-dd>,to=<yyyy-MM-dd>,csvSeparator,level,selectCodes,presentationNamePattern}",
"templated" : true
},
"variantAt" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131/variantAt{?variantName,date=<yyyy-MM-dd>,csvSeparator,level,selectCodes,presentationNamePattern}",
"templated" : true
},
"corresponds" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131/corresponds{?targetClassificationId,from=<yyyy-MM-dd>,to=<yyyy-MM-dd>,csvSeparator}",
"templated" : true
},
"correspondsAt" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131/correspondsAt{?targetClassificationId,date=<yyyy-MM-dd>,csvSeparator}",
"templated" : true
},
"changes" : {
"href" : "https://data.ssb.no/api/klass/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 |
---|---|---|
|
|
Classification name |
|
|
Description of classification |
|
|
Primary language for classification |
|
|
Type of classification, Classification or Codelist |
|
|
If true, classification is copyrighted |
|
|
If true, indicates that classificationItems may have shortnames |
|
|
If true, indicates that classificationItems may have notes |
|
|
Contact person for classification |
|
|
Owning SSB section |
|
|
Statistical units assigned to classification |
|
|
Last time classification has been modified |
|
|
Array of classification versions |
|
|
Links to operations on classification |
2.3.5. Links
Relation | Description |
---|---|
|
The current request |
|
Used for getting codes from the classification, see codes |
|
Used for getting codes from the classification valid at a specific date, see codesAt |
|
Used for getting codes from a classification variant, see variant |
|
Used for getting codes from a variant of the classification valid at a specific date, see variantAt |
|
Used for getting mappings between two classifications, see corresponds |
|
Used for getting mappings between two classifications at a specific date, see correspondsAt |
|
Used for getting changes in codes, see changes |
2.3.6. Request parameters
Parameter | Description |
---|---|
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[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 'https://data.ssb.no/api/klass/v1/classifications/131/codes?from=2020-01-01&to=2021-01-01&csvSeparator=;' -i -X GET \
-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 |
---|---|
|
[Mandatory] specifies beginning of range with format |
|
[Optional] specifies end of range with format |
|
[Optional] specifies separator to be used for csv format. For details see csvSeparator |
|
[Optional] specifies which fields should be included in the csv output. For details see csvfields |
|
[Optional] only return codes that match pattern given by selectCodes. For details see selectCodes |
|
[Optional] only return codes with matching level. For details see selectLevel |
|
[Optional] used to build a presentationName. For details see presentationNamePattern |
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[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 'https://data.ssb.no/api/klass/v1/classifications/104/codesAt?date=2020-01-01' -i -X GET \
-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 |
---|---|
|
[Mandatory] specifies codes at a certain date with format |
|
[Optional] specifies separator to be used for csv format. For details see csvSeparator |
|
[Optional] specifies which fields should be included in the csv output. For details see csvfields |
|
[Optional] only return codes that match pattern given by selectCodes. For details see selectCodes |
|
[Optional] only return codes with matching level. For details see selectLevel |
|
[Optional] used to build a presentationName. For details see presentationNamePattern |
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[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 |
---|---|
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[Optional] include future versions if available. Default is false. |
2.6.4. Example request (JSON with UTF-8)
$ curl 'https://data.ssb.no/api/klass/v1/versions/131' -i -X GET \
-H 'Accept: application/json'
2.6.5. Response structure (JSON, XML)
Path | Type | Description |
---|---|---|
|
|
Version name |
|
|
Date the version is valid from |
|
|
Date the version is valid to |
|
|
Time and date the version was last time modified at |
|
|
List of languages the version is published in |
|
|
Version description |
|
|
Legal base |
|
|
Source references |
|
|
Derived from |
|
|
List of correspondence tables for the version |
|
|
List of classification variants for the version |
|
|
Log og changes |
|
|
List of levels |
|
|
Array of classification items |
|
|
Links to operations on the version |
2.6.6. Response structure (JSON, XML)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1387
{
"name" : "Kommuneinndeling 2012",
"id" : 1,
"validFrom" : "2012-01-01",
"validTo" : "2014-01-01",
"lastModified" : "2024-06-26T11:35:20.564+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" : "https://data.ssb.no/api/klass/api/klass/v1/versions/1"
}
}
}
2.6.7. Example request (CSV with ISO-8859-1)
$ curl 'https://data.ssb.no/api/klass/v1/versions/131' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/84/variant?variantName=Klimagasser&from=2020-01-01&to=2021-01-01' -i -X GET \
-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 |
---|---|
|
[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 |
|
[Mandatory] specifies beginning of range with format |
|
[Optional] specifies end of range with format |
|
[Optional] specifies separator to be used for csv format. For details see csvSeparator |
|
[Optional] specifies which fields should be included in the csv output. For details see csvfields |
|
[Optional] only return codes that match pattern given by selectCodes. For details see selectCodes |
|
[Optional] only return codes with matching level. For details see selectLevel |
|
[Optional] used to build a presentationName. For details see presentationNamePattern |
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[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 'https://data.ssb.no/api/klass/v1/classifications/84/variantAt?variantName=Klimagasser&date=2015-01-01' -i -X GET \
-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 |
---|---|
|
[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 |
|
[Mandatory] specifies codes at a certain date with format |
|
[Optional] specifies separator to be used for csv format. For details see csvSeparator |
|
[Optional] specifies which fields should be included in the csv output. For details see csvfields |
|
[Optional] only return codes that match pattern given by selectCodes. For details see selectCodes |
|
[Optional] only return codes with matching level. For details see selectLevel |
|
[Optional] used to build a presentationName. For details see presentationNamePattern |
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[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 |
---|---|
|
[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 'https://data.ssb.no/api/klass/v1/variants/1111' -i -X GET \
-H 'Accept: application/json'
2.9.5. Response structure (JSON, XML)
Path | Type | Description |
---|---|---|
|
|
Variant name |
|
|
Contact information to the SSB section representative |
|
|
SSB section number |
|
|
Time and date the variant was last time modified at |
|
|
List of languages the version is published in |
|
|
Date the variant is valid from |
|
|
Date the variant is valid to |
|
|
Variant description |
|
|
List of correspondence tables for the variant |
|
|
Log of changes |
|
|
List of levels |
|
|
Array of classification items |
|
|
Links to operations on the variant |
2.9.6. Response structure (JSON, XML)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1480
{
"name" : "Variant - Tilleggsinndeling for familier 2006 - variant av Gruppering av familier 2006",
"id" : 1111,
"contactPerson" : {
"name" : "Ziggy Stardust",
"email" : null,
"phone" : null
},
"owningSection" : "section",
"lastModified" : "2024-06-26T11:35:20.589+0000",
"published" : [ "nb" ],
"validFrom" : "2006-01-01",
"validTo" : "2034-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" : "https://data.ssb.no/api/klass/api/klass/v1/variants/1111"
}
}
}
2.9.7. Example request (CSV with ISO-8859-1)
$ curl 'https://data.ssb.no/api/klass/v1/variants/1111' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/131/corresponds?targetClassificationId=103&from=2020-01-01&to=2021-01-01' -i -X GET \
-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 |
---|---|
|
[Mandatory] specifies id of target classification |
|
[Mandatory] specifies beginning of range with format |
|
[Optional] specifies end of range with format |
|
[Optional] specifies which fields should be included in the csv output. For details see csvfields |
|
[Optional] specifies separator to be used for csv format. For details see csvSeparator |
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[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 'https://data.ssb.no/api/klass/v1/classifications/131/correspondsAt?targetClassificationId=103&date=2018-01-01' -i -X GET \
-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 |
---|---|
|
[Mandatory] specifies id of target classification |
|
[Mandatory] specifies codes at a certain date with format |
|
[Optional] specifies separator to be used for csv format. For details see csvSeparator |
|
[Optional] specifies which fields should be included in the csv output. For details see csvfields |
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[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 'https://data.ssb.no/api/klass/v1/correspondencetables/1' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/correspondencetables/1' -i -X GET \
-H 'Accept: application/json'
2.12.6. Response structure (JSON, XML)
Path | Type | Description |
---|---|---|
|
|
Correspondence table’s name |
|
|
Contact information to the SSB section representative |
|
|
SSB section number |
|
|
Name to the source classification version |
|
|
ID to the source classification version |
|
|
Name to the target classification version |
|
|
ID to the target classification version |
|
|
Changes done to the table |
|
|
Timestamp for the last modifications done to the table |
|
|
A list of the languages the correspondence table is published in |
|
|
Level name and number for the source classification version |
|
|
Level name and number for the target classification version |
|
|
Description |
|
|
A list of the changes done to the correspondence table |
|
|
A list of the mappings the correspondence table includes |
|
|
links to operations on classificationFamily |
2.12.7. Example response (JSON with UTF-8)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1132
{
"name" : "Arbeidsgiveravgiftssoner 2012 - Kommuneinndeling 2012",
"id" : 1,
"contactPerson" : {
"name" : "Ziggy Stardust",
"email" : null,
"phone" : null
},
"owningSection" : "section",
"source" : "Arbeidsgiveravgiftssoner 2012",
"sourceId" : 2,
"target" : "Kommuneinndeling 2012",
"targetId" : 7,
"changeTable" : false,
"lastModified" : "2024-06-26T11:35:19.643+0000",
"published" : [ "nb" ],
"sourceLevel" : null,
"targetLevel" : null,
"description" : "Mapping Arbeidsgiveravgiftssoner - Kommuneinndeling",
"changelogs" : [ ],
"correspondenceMaps" : [ {
"sourceCode" : "01",
"sourceName" : "Oslo",
"targetCode" : "0301",
"targetName" : "Oslo"
} ],
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/correspondencetables/1"
},
"source" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/versions/2{?language,includeFuture}",
"templated" : true
},
"target" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/versions/7{?language,includeFuture}",
"templated" : true
}
}
}
2.12.8. Links
Relation | Description |
---|---|
|
The current request |
|
Table’s source classification version |
|
Table’s target classification version |
2.12.9. Request parameters
Parameter | Description |
---|---|
|
[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 'https://data.ssb.no/api/klass/v1/classifications/131/changes?from=2020-01-01&to=2021-01-01' -i -X GET \
-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 |
---|---|
|
[Mandatory] specifies beginning of range with format |
|
[Optional] specifies end of range with format |
|
[Optional] specifies separator to be used for csv format. For details see csvSeparator |
|
[Optional] specifies language of retrieved data. Default is nb (Norwegian Bokmål). For details see language |
|
[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 'https://data.ssb.no/api/klass/v1/classificationfamilies' -i -X GET \
-H 'Accept: application/json'
2.14.3. Example response (JSON)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 409
{
"_embedded" : {
"classificationFamilies" : [ {
"name" : "Befolkning",
"id" : 3,
"numberOfClassifications" : 1,
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classificationfamilies/3"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/v1/classificationfamilies"
}
}
}
2.14.4. Response structure
Path | Type | Description |
---|---|---|
|
|
An array of ClassificationFamilies |
|
|
ClassificationFamily name |
|
|
Number of classifications belonging to classificationFamily |
|
|
Link to classificationFamily |
|
|
Links to other resources |
2.14.5. Links
Relation | Description |
---|---|
|
The current request |
2.14.6. Request parameters
Parameter | Description |
---|---|
|
[Optional] only include classifications belonging to specified SSB section when counting number of classifications. Default is all SSB sections |
|
[Optional] include codelists when counting number of classifications. Default is false |
|
[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 'https://data.ssb.no/api/klass/v1/classificationfamilies/3' -i -X GET \
-H 'Accept: application/json'
2.15.3. Example response (JSON)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 488
{
"name" : "Befolkning",
"id" : 3,
"classifications" : [ {
"name" : "Standard for kommuneinndeling",
"id" : 131,
"classificationType" : "Klassifikasjon",
"lastModified" : "2024-06-26T11:35:20.677+0000",
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131"
}
}
} ],
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classificationfamilies/3"
}
}
}
2.15.4. Response structure
Path | Type | Description |
---|---|---|
|
|
ClassificationFamily name |
|
|
Array of classifications |
|
|
Links to operations on classificationFamily |
2.15.5. Links
Relation | Description |
---|---|
|
The current request |
2.15.6. Request parameters
Parameter | Description |
---|---|
|
[Optional] only include classifications belonging to specified SSB section when listing classifications. Default is all SSB sections |
|
[Optional] include codelists when listing classifications. Default is false |
|
[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 'https://data.ssb.no/api/klass/v1/ssbsections' -i -X GET \
-H 'Accept: application/json'
2.16.3. Example response (JSON)
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 240
{
"_embedded" : {
"ssbSections" : [ {
"name" : "Seksjon for primærnæringsstatistikk (420)",
"id" : null
} ]
},
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/v1/ssbsections"
}
}
}
2.16.4. Response structure
Path | Type | Description |
---|---|---|
|
|
Array of ssb sections |
|
|
Name of ssb section |
|
|
Links to operations on ssb sections |
2.16.5. Links
Relation | Description |
---|---|
|
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 'https://data.ssb.no/api/klass/v1/classifications/131/codes?from=2019-01-01&to=2020-01-01' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/131/codes?from=2019-01-01&to=2021-01-01' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications?changedSince=2015-03-01T01:30:00.000-0200' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/131/codes?from=2020-01-01&to=2021-01-01&selectCodes=3415-3418,300*' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/131/codes?from=2020-01-01&to=2021-01-01&csvSeparator=;' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/131/codesAt?date=2020-01-01&csvSeparator=;&csvFields=name,code' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/131/codes?from=2015-01-01&to=2016-01-01&language=nb' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/17/codes?from=2020-01-01&to=2021-01-01&selectLevel=2' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/131/codes?from=2020-01-01&to=2021-01-01&presentationNamePattern=%7Bcode%7D-%7Buppercase(name)%7D' -i -X GET \
-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 'https://data.ssb.no/api/klass/v1/classifications/search?query=kommuner&includeCodelists=true&ssbSection=370' -i -X GET \
-H 'Accept: application/json'
3.9.2. Example response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 636
{
"_embedded" : {
"searchResults" : [ {
"name" : "Standard for kommuneinndeling",
"id" : 131,
"snippet" : "Kommuneinndelingen er en administrativ inndeling av Norge",
"searchScore" : 8.0,
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "https://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 'https://data.ssb.no/api/klass/v1/classifications?size=2' -i -X GET \
-H 'Accept: application/json'
4.1.2. Example response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1362
{
"_embedded" : {
"classifications" : [ {
"name" : "Standard for kommuneinndeling",
"id" : 131,
"classificationType" : "Klassifikasjon",
"lastModified" : "2024-06-26T11:35:20.747+0000",
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/131"
}
}
}, {
"name" : "Standard for bydelsinndeling",
"id" : 103,
"classificationType" : "Klassifikasjon",
"lastModified" : "2024-06-26T11:35:20.747+0000",
"_links" : {
"self" : {
"href" : "https://data.ssb.no/api/klass/api/klass/v1/classifications/103"
}
}
} ]
},
"_links" : {
"first" : {
"href" : "https://data.ssb.no/api/klass/v1/classifications?page=0&size=2"
},
"self" : {
"href" : "https://data.ssb.no/api/klass/v1/classifications?size=2"
},
"next" : {
"href" : "https://data.ssb.no/api/klass/v1/classifications?page=1&size=2"
},
"last" : {
"href" : "https://data.ssb.no/api/klass/v1/classifications?page=1&size=2"
},
"search" : {
"href" : "https://data.ssb.no/api/klass/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 |
---|---|---|
|
|
Size of a page (number of elements per page) |
|
|
Total number of elements in collection |
|
|
Total number of pages |
|
|
Page number |
4.1.4. Links
Relation | Description |
---|---|
|
The current request |
|
Search |
|
First page |
|
Next page |
|
Last page |