{
  "openapi": "3.1.0",
  "info": {
    "title": "Strømpriser i dag API",
    "version": "1.0.0",
    "summary": "Norwegian electricity spot prices (NO1–NO5) and grid tariffs for all 73 grid companies. No key, no sign-up, CORS open.",
    "description": "Hourly spot prices for the five Norwegian price areas, with VAT and the state electricity support (strømstøtte) already worked out, plus hourly grid tariffs (nettleie) for every Norwegian grid company.\n\nNo key is required. An optional free key raises the hourly limit from 120 to 2000 requests. Field names are English; free-text notes are in Norwegian.\n\nPrices: Nord Pool via ENTSO-E. Grid tariffs: Fri Nettleie (kraftsystemet/fri-nettleie), CC BY 4.0. Free to use with a link to strompriseridag.no.",
    "contact": {
      "name": "strompriseridag.no",
      "url": "https://strompriseridag.no/kontakt/"
    },
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "termsOfService": "https://strompriseridag.no/vilkar/"
  },
  "externalDocs": {
    "description": "Documentation (Norwegian)",
    "url": "https://strompriseridag.no/api/"
  },
  "servers": [
    {
      "url": "https://api.strompriseridag.no"
    }
  ],
  "security": [
    {},
    {
      "bearerKey": []
    },
    {
      "queryKey": []
    }
  ],
  "tags": [
    {
      "name": "prices",
      "description": "Spot prices per price area"
    },
    {
      "name": "grid-tariffs",
      "description": "Grid tariffs (nettleie) per grid company"
    },
    {
      "name": "keys",
      "description": "Optional API keys"
    }
  ],
  "paths": {
    "/v1/{zone}": {
      "get": {
        "tags": [
          "prices"
        ],
        "operationId": "getPrices",
        "summary": "Today's and tomorrow's hourly prices for one price area",
        "description": "Tomorrow's prices are published around 13:00 Europe/Oslo; until then `tomorrow` is null and `tomorrow_available` is false.",
        "parameters": [
          {
            "name": "zone",
            "in": "path",
            "required": true,
            "description": "Price area. NO1 Oslo, NO2 Kristiansand, NO3 Trondheim, NO4 Tromsø, NO5 Bergen.",
            "schema": {
              "type": "string",
              "enum": [
                "NO1",
                "NO2",
                "NO3",
                "NO4",
                "NO5"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Prices",
            "headers": {
              "x-ratelimit-limit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "x-ratelimit-remaining": {
                "$ref": "#/components/headers/RateRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Prices"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnknownKey"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/nettleie": {
      "get": {
        "tags": [
          "grid-tariffs"
        ],
        "operationId": "listGridTariffs",
        "summary": "All 73 grid companies with effective energy price and annual cost",
        "responses": {
          "200": {
            "description": "Overview",
            "headers": {
              "x-ratelimit-limit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "x-ratelimit-remaining": {
                "$ref": "#/components/headers/RateRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GridTariffIndex"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnknownKey"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/nettleie/{id}": {
      "get": {
        "tags": [
          "grid-tariffs"
        ],
        "operationId": "getGridTariff",
        "summary": "Hourly grid tariff for one company, today and tomorrow",
        "description": "`current` and `next_change` are computed at request time, so they are safe to use in automations.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The `id` field from /v1/nettleie, e.g. `elvia` or `alut`.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tariff",
            "headers": {
              "x-ratelimit-limit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "x-ratelimit-remaining": {
                "$ref": "#/components/headers/RateRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GridTariff"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnknownKey"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/keys": {
      "post": {
        "tags": [
          "keys"
        ],
        "operationId": "createKey",
        "summary": "Create an optional key (higher limit). Shown once.",
        "security": [
          {}
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "description": "Optional, only used to announce API changes."
                  },
                  "label": {
                    "type": "string",
                    "maxLength": 60
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Key created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "key",
                    "created",
                    "limit_per_hour"
                  ],
                  "properties": {
                    "key": {
                      "type": "string",
                      "pattern": "^sp_live_[0-9a-f]{32}$"
                    },
                    "created": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "email": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "note": {
                      "type": "string"
                    },
                    "limit_per_hour": {
                      "type": "integer"
                    },
                    "docs": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "tags": [
          "keys"
        ],
        "operationId": "deleteKey",
        "summary": "Delete your own key",
        "security": [
          {
            "bearerKey": []
          },
          {
            "queryKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnknownKey"
          }
        }
      }
    },
    "/keys/me": {
      "get": {
        "tags": [
          "keys"
        ],
        "operationId": "getKey",
        "summary": "Look up your own key",
        "security": [
          {
            "bearerKey": []
          },
          {
            "queryKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Key metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "created": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "email": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "label": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "last_seen": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "limit_per_hour": {
                      "type": "integer"
                    },
                    "usage_note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnknownKey"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Optional. Raises the limit to 2000 requests/hour."
      },
      "queryKey": {
        "type": "apiKey",
        "in": "query",
        "name": "key",
        "description": "Optional. Same key as a query parameter."
      }
    },
    "responses": {
      "NotFound": {
        "description": "Unknown endpoint or company",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "UnknownKey": {
        "description": "A key was given but is not known. Remove it or create a new one.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Hourly limit reached",
        "headers": {
          "retry-after": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds until the window resets"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unavailable": {
        "description": "Upstream data temporarily unavailable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "hint": {
            "type": "string"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "limit_per_hour": {
            "type": "integer"
          }
        }
      },
      "DaySummary": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "hours": {
            "type": "integer",
            "description": "23, 24 or 25 on DST change days"
          },
          "average_ore": {
            "type": "number"
          },
          "average_after_support_ore": {
            "type": "number"
          },
          "min_ore": {
            "type": "number"
          },
          "min_start": {
            "type": "string",
            "format": "date-time"
          },
          "max_ore": {
            "type": "number"
          },
          "max_start": {
            "type": "string",
            "format": "date-time"
          },
          "hours_above_support_threshold": {
            "type": "integer"
          }
        }
      },
      "PriceHour": {
        "type": "object",
        "required": [
          "start",
          "end",
          "price_ore"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "hour": {
            "type": "integer",
            "minimum": 0,
            "maximum": 23
          },
          "spot_ore_ex_vat": {
            "type": "number",
            "description": "Spot price, øre/kWh, excluding VAT"
          },
          "price_ore": {
            "type": "number",
            "description": "Spot price including VAT where VAT applies"
          },
          "price_after_support_ore": {
            "type": "number",
            "description": "What a household pays after strømstøtte (per kWh, below the monthly cap)"
          },
          "support_ore": {
            "type": "number"
          },
          "tomorrow": {
            "type": "boolean"
          }
        }
      },
      "CheapestWindow": {
        "type": "object",
        "properties": {
          "hours": {
            "type": "integer"
          },
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "average_ore": {
            "type": "number"
          },
          "average_after_support_ore": {
            "type": "number"
          },
          "spans_midnight": {
            "type": "boolean"
          },
          "starts_tomorrow": {
            "type": "boolean"
          }
        }
      },
      "Prices": {
        "type": "object",
        "required": [
          "zone",
          "currency",
          "unit",
          "today_available",
          "tomorrow_available",
          "series",
          "generated_at"
        ],
        "properties": {
          "zone": {
            "type": "string",
            "enum": [
              "NO1",
              "NO2",
              "NO3",
              "NO4",
              "NO5"
            ]
          },
          "region": {
            "type": "string"
          },
          "main_city": {
            "type": "string"
          },
          "currency": {
            "const": "NOK"
          },
          "unit": {
            "const": "øre/kWh"
          },
          "vat_included": {
            "type": "boolean",
            "description": "False for NO4, where households are exempt from VAT on electricity"
          },
          "vat_note": {
            "type": "string"
          },
          "resolution": {
            "type": "string",
            "description": "ISO 8601 duration of each entry in `series`"
          },
          "resolution_note": {
            "type": "string"
          },
          "support_threshold_ore_ex_vat": {
            "type": "number"
          },
          "support_share": {
            "type": "number"
          },
          "support_note": {
            "type": "string"
          },
          "norgespris_ore_ex_vat": {
            "type": "number",
            "description": "The fixed Norgespris, for comparison"
          },
          "today_available": {
            "type": "boolean"
          },
          "tomorrow_available": {
            "type": "boolean"
          },
          "tomorrow_expected_after": {
            "type": "string"
          },
          "today": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DaySummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "tomorrow": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DaySummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PriceHour"
            }
          },
          "cheapest_windows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CheapestWindow"
            }
          },
          "source": {
            "type": "string"
          },
          "attribution": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AnnualCost": {
        "type": "object",
        "properties": {
          "energy": {
            "type": "number"
          },
          "capacity": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "basis": {
            "type": "object",
            "properties": {
              "consumption_kwh": {
                "type": "number"
              },
              "peak_kw": {
                "type": "number"
              }
            }
          }
        }
      },
      "GridCompanySummary": {
        "type": "object",
        "required": [
          "id",
          "name",
          "effective_energy_ore_per_kwh"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "legal_name": {
            "type": "string"
          },
          "gln": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "counties": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "customers": {
            "type": [
              "integer",
              "null"
            ]
          },
          "capacity_model": {
            "type": [
              "string",
              "null"
            ]
          },
          "effective_energy_ore_per_kwh": {
            "type": "number",
            "description": "Energy charge weighted against a real Elhub household consumption profile, not by hour count"
          },
          "time_of_use": {
            "type": "boolean",
            "description": "Whether the energy charge changes during the day"
          },
          "annual_cost_nok": {
            "$ref": "#/components/schemas/AnnualCost"
          },
          "outdated": {
            "type": "boolean"
          },
          "tariff_updated": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "valid_from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "valid_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "detail": {
            "type": "string",
            "format": "uri"
          },
          "page": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "GridTariffIndex": {
        "type": "object",
        "required": [
          "companies",
          "source_fetched"
        ],
        "properties": {
          "unit": {
            "type": "string"
          },
          "currency": {
            "const": "NOK"
          },
          "vat_included": {
            "type": "boolean"
          },
          "vat_note": {
            "type": "string"
          },
          "assumptions": {
            "type": "object"
          },
          "limitations": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "company_count": {
            "type": "integer"
          },
          "customers_covered": {
            "type": "integer"
          },
          "time_of_use_count": {
            "type": "integer"
          },
          "median_energy_ore_per_kwh": {
            "type": "number"
          },
          "median_annual_total_nok": {
            "type": "number"
          },
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GridCompanySummary"
            }
          },
          "source": {
            "type": "string"
          },
          "source_url": {
            "type": "string",
            "format": "uri"
          },
          "source_fetched": {
            "type": "string",
            "format": "date"
          },
          "license": {
            "type": "string"
          },
          "attribution": {
            "type": "string"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TariffHour": {
        "type": "object",
        "required": [
          "start",
          "end",
          "ore_per_kwh"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "hour": {
            "type": "integer"
          },
          "ore_per_kwh": {
            "type": "number"
          },
          "periode": {
            "type": [
              "string",
              "null"
            ],
            "description": "Tariff period name from the source, e.g. dag/natt"
          }
        }
      },
      "TariffDay": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "hours": {
            "type": "integer"
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TariffHour"
            }
          }
        }
      },
      "GridTariff": {
        "allOf": [
          {
            "$ref": "#/components/schemas/GridCompanySummary"
          }
        ],
        "type": "object",
        "properties": {
          "unit": {
            "type": "string"
          },
          "currency": {
            "const": "NOK"
          },
          "vat_included": {
            "type": "boolean"
          },
          "vat_note": {
            "type": "string"
          },
          "current_computed_at": {
            "type": "string",
            "format": "date-time",
            "description": "When `current` was computed. On api.strompriseridag.no this is recomputed per request."
          },
          "current_note": {
            "type": "string"
          },
          "index": {
            "type": "string",
            "format": "uri"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          },
          "base_ore_per_kwh": {
            "type": "number"
          },
          "current": {
            "type": [
              "object",
              "null"
            ],
            "description": "The tariff in force right now; computed per request",
            "properties": {
              "ore_per_kwh": {
                "type": "number"
              },
              "period": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "start": {
                "type": "string",
                "format": "date-time"
              },
              "end": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "next_change": {
            "type": [
              "object",
              "null"
            ],
            "description": "Next time the energy charge changes, looking into tomorrow if needed; null for flat tariffs",
            "properties": {
              "at": {
                "type": "string",
                "format": "date-time"
              },
              "to_ore_per_kwh": {
                "type": "number"
              },
              "period": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "direction": {
                "type": "string",
                "enum": [
                  "cheaper",
                  "more_expensive"
                ]
              }
            }
          },
          "today": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TariffDay"
              },
              {
                "type": "null"
              }
            ]
          },
          "tomorrow": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TariffDay"
              },
              {
                "type": "null"
              }
            ]
          },
          "cheapest_windows_today": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CheapestWindow"
            }
          },
          "capacity": {
            "type": "object",
            "description": "Capacity charge (kapasitetsledd) steps",
            "properties": {
              "model": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "threshold_included": {
                "type": "boolean"
              },
              "steps": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "from_kw": {
                      "type": "number"
                    },
                    "nok_per_year": {
                      "type": "number"
                    }
                  }
                }
              },
              "example_nok_per_year": {
                "type": "number"
              },
              "example_peak_kw": {
                "type": "number"
              }
            }
          },
          "limitations": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "source": {
            "type": "string"
          },
          "source_url": {
            "type": "string",
            "format": "uri"
          },
          "source_fetched": {
            "type": "string",
            "format": "date"
          },
          "license": {
            "type": "string"
          },
          "attribution": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "headers": {
      "RateLimit": {
        "schema": {
          "type": "integer"
        },
        "description": "120 without a key, 2000 with one"
      },
      "RateRemaining": {
        "schema": {
          "type": "integer"
        },
        "description": "Requests left in the current hour"
      }
    }
  }
}
