{
  "openapi": "3.1.0",
  "info": {
    "title": "Offentlige data – Norge — data API",
    "version": "1.0.0",
    "description": "Read-only JSON mirror of public Norwegian statistics from Statistics Norway (SSB), the Norwegian Water Resources and Energy Directorate (NVE), day-ahead spot prices (hvakosterstrommen.no, from ENTSO-E) and the Directorate of Integration and Diversity (IMDi), refreshed automatically (SSB, NVE and hvakosterstrømmen.no daily, IMDi weekly). No authentication; CORS-open. Licences per dataset are listed in the catalog — attribute the upstream source when reusing.",
    "license": {
      "name": "Per dataset: SSB CC BY 4.0; NVE NLOD 2.0; hvakosterstrømmen.no free to use, credit requested (\"Strømpriser levert av Hva koster strømmen.no\"); IMDi NLOD 2.0 — see /api/datasets",
      "url": "https://drawmeariver.org/kilder"
    }
  },
  "servers": [
    {
      "url": "https://drawmeariver.org"
    }
  ],
  "security": [],
  "paths": {
    "/api/datasets": {
      "get": {
        "operationId": "listDatasets",
        "summary": "List every dataset with labels, source, licence, fetch time and URLs",
        "responses": {
          "200": {
            "description": "Dataset catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "datasets": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "<source>/<slug>"
                          },
                          "label_nb": {
                            "type": "string"
                          },
                          "label_en": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "upstream_title": {
                            "type": "string"
                          },
                          "publisher": {
                            "type": "string"
                          },
                          "table_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "table_url": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uri"
                          },
                          "license": {
                            "type": "string"
                          },
                          "license_url": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uri"
                          },
                          "fetched_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "period_first": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "description": "First period code in the rows served at data_url"
                          },
                          "period_last": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "description": "Last period code in the rows served at data_url"
                          },
                          "used_on": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "format": "uri"
                            }
                          },
                          "data_url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "meta_url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "landing_page": {
                            "type": "string",
                            "format": "uri"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/data/{source}/{slug}": {
      "get": {
        "operationId": "getDataset",
        "summary": "Dataset rows as produced by the ETL",
        "description": "Most datasets are `{ rows: [{ <dimension>: <label>, Tid: <period>, value: <number> }] }` where Tid uses SSB period codes (2024, 2024M01, 2024K1). NVE and spot-price datasets have source-specific shapes; see the provenance endpoint for dimensions and the upstream query.",
        "parameters": [
          {
            "name": "source",
            "in": "path",
            "required": true,
            "description": "Data source folder: ssb = Statistics Norway (SSB), nve = the Norwegian Water Resources and Energy Directorate (NVE), kraft = day-ahead spot prices (hvakosterstrommen.no, from ENTSO-E), imdi = the Directorate of Integration and Diversity (IMDi)",
            "schema": {
              "type": "string",
              "enum": [
                "ssb",
                "nve",
                "kraft",
                "imdi"
              ]
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Dataset slug. See GET /api/datasets for which slug belongs to which source.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$",
              "enum": [
                "aap",
                "aku-rater",
                "aldersgrupper",
                "aldersgrupper-framskrevet",
                "anmeldte-lovbrudd",
                "ansatte-staten",
                "arbeidsledige",
                "befolkning",
                "befolkning-endringer",
                "boligpris-ar",
                "boligpris-kvartal",
                "bosetting-kommune",
                "deltid",
                "forste-bosettingskommune",
                "fruktbarhet",
                "gjeld-desil",
                "husleie",
                "inn-utvandring-kommune",
                "inntekt-desil",
                "inntekt-husholdning",
                "innvandrere-kommune",
                "innvandrere-kommune-land",
                "innvandrere-land",
                "innvandrere-oslo-bydel",
                "innvandrere-verdensdel",
                "innvandringsgrunn",
                "innvandringsgrunn-bosatt",
                "innvandringsgrunn-kommune",
                "kollektiv-beskyttelse-kommune",
                "kommune-befolkning",
                "kommune-endringer",
                "kommune-inntekt",
                "kpi",
                "kraftpris",
                "kraftproduksjon",
                "levealder",
                "levealder-historisk",
                "lovbrudd-kommune",
                "magasin-fylling",
                "medianalder-kommune",
                "nettleie-fylke",
                "nettoformue",
                "offentlig-sysselsetting",
                "personoffer",
                "spotpris",
                "straffereaksjoner",
                "strom-forbruk-sektor",
                "sykefravaer",
                "sykefravaer-naring",
                "sysselsatte-naring",
                "sysselsetting-andel",
                "sysselsetting-andel-kommune",
                "sysselsetting-kommune",
                "ufore-kommune",
                "uforetrygdede"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dataset JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Unknown source or dataset, or malformed slug",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown source or dataset, or malformed slug",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/data/{source}/{slug}/meta": {
      "get": {
        "operationId": "getDatasetMeta",
        "summary": "Provenance: upstream table, exact query, fetch time, licence, dimensions",
        "parameters": [
          {
            "name": "source",
            "in": "path",
            "required": true,
            "description": "Data source folder: ssb = Statistics Norway (SSB), nve = the Norwegian Water Resources and Energy Directorate (NVE), kraft = day-ahead spot prices (hvakosterstrommen.no, from ENTSO-E), imdi = the Directorate of Integration and Diversity (IMDi)",
            "schema": {
              "type": "string",
              "enum": [
                "ssb",
                "nve",
                "kraft",
                "imdi"
              ]
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Dataset slug. See GET /api/datasets for which slug belongs to which source.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$",
              "enum": [
                "aap",
                "aku-rater",
                "aldersgrupper",
                "aldersgrupper-framskrevet",
                "anmeldte-lovbrudd",
                "ansatte-staten",
                "arbeidsledige",
                "befolkning",
                "befolkning-endringer",
                "boligpris-ar",
                "boligpris-kvartal",
                "bosetting-kommune",
                "deltid",
                "forste-bosettingskommune",
                "fruktbarhet",
                "gjeld-desil",
                "husleie",
                "inn-utvandring-kommune",
                "inntekt-desil",
                "inntekt-husholdning",
                "innvandrere-kommune",
                "innvandrere-kommune-land",
                "innvandrere-land",
                "innvandrere-oslo-bydel",
                "innvandrere-verdensdel",
                "innvandringsgrunn",
                "innvandringsgrunn-bosatt",
                "innvandringsgrunn-kommune",
                "kollektiv-beskyttelse-kommune",
                "kommune-befolkning",
                "kommune-endringer",
                "kommune-inntekt",
                "kpi",
                "kraftpris",
                "kraftproduksjon",
                "levealder",
                "levealder-historisk",
                "lovbrudd-kommune",
                "magasin-fylling",
                "medianalder-kommune",
                "nettleie-fylke",
                "nettoformue",
                "offentlig-sysselsetting",
                "personoffer",
                "spotpris",
                "straffereaksjoner",
                "strom-forbruk-sektor",
                "sykefravaer",
                "sykefravaer-naring",
                "sysselsatte-naring",
                "sysselsetting-andel",
                "sysselsetting-andel-kommune",
                "sysselsetting-kommune",
                "ufore-kommune",
                "uforetrygdede"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Metadata sidecar",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Unknown source or dataset, or malformed slug",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown source or dataset, or malformed slug",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/kommuner": {
      "get": {
        "operationId": "listKommuner",
        "summary": "Every municipality (kommune) with code, county, newest population and profile URL",
        "description": "Use it to resolve a municipality name to the `slug` used by /api/kommuner/{slug}. Two kommuner share a name (Herøy, Våler); their slugs carry the county.",
        "responses": {
          "200": {
            "description": "Municipality list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "kommuner": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string",
                            "description": "4-digit kommunenummer"
                          },
                          "name": {
                            "type": "string"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "county": {
                            "type": "string"
                          },
                          "county_code": {
                            "type": "string"
                          },
                          "population": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "population_date": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date"
                          },
                          "page_url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "profile_url": {
                            "type": "string",
                            "format": "uri"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/kommuner/{slug}": {
      "get": {
        "operationId": "getKommune",
        "summary": "One municipality's key figures, each with period, national comparison and source",
        "description": "Population history (1 January), births, deaths and net migration, and the indicators median age, median household income after tax, disability-benefit recipients as a percentage of the population aged 18–67 (SSB's own figure), reported offences per 1,000 inhabitants (two-year average, by where the offence took place), employment rate, public-administration employment share (state, municipal and county administration), immigrant share and county grid tariff. Values are rounded as on the page. Each indicator gives its reference period and the national value for the same period. An `immigration` block adds the largest countries of origin and moves to and from abroad.",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "From /api/kommuner, e.g. larvik",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Municipality profile",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Unknown source or dataset, or malformed slug",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown source or dataset, or malformed slug",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/geo/{slug}": {
      "get": {
        "operationId": "getGeo",
        "summary": "Boundary GeoJSON (municipalities: slug = kommuner)",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "kommuner"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "GeoJSON FeatureCollection",
            "content": {
              "application/geo+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    }
  }
}