{
  "openapi": "3.1.0",
  "info": {
    "title": "Elpriser i dag API",
    "version": "1.0.0",
    "summary": "Swedish electricity spot prices (SE1–SE4) in 15-minute intervals with VAT and energy tax, plus grid fees for 188 grid companies. No key, no sign-up, CORS open.",
    "description": "Quarter-hourly spot prices for the four Swedish bidding zones, with VAT and energy tax already added – the price a household actually pays – and the reduced energy tax for the 46 northern municipalities given separately. Also grid fees (elnätsavgifter) for 188 grid companies, 2022–2026, from Energimarknadsinspektionen.\n\nNo key is required. An optional free key raises the hourly limit from 120 to 2000 requests. Field names and notes are in Swedish.\n\nPrices: Nord Pool via elprisetjustnu.se. Grid fees: Energimarknadsinspektionen (Ei). Free to use with a link to elprisernaidag.se.",
    "contact": {
      "name": "elprisernaidag.se",
      "email": "kontakt@elprisernaidag.se",
      "url": "https://elprisernaidag.se/om/"
    },
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "termsOfService": "https://elprisernaidag.se/villkor/"
  },
  "externalDocs": {
    "description": "Documentation (Swedish)",
    "url": "https://elprisernaidag.se/api/"
  },
  "servers": [
    {
      "url": "https://api.elprisernaidag.se"
    }
  ],
  "security": [
    {},
    {
      "bearerKey": []
    },
    {
      "queryKey": []
    }
  ],
  "tags": [
    {
      "name": "priser",
      "description": "Spot prices per bidding zone"
    },
    {
      "name": "elnatsavgifter",
      "description": "Grid fees per grid company"
    },
    {
      "name": "nycklar",
      "description": "Optional API keys"
    }
  ],
  "paths": {
    "/v1/{elomrade}": {
      "get": {
        "tags": [
          "priser"
        ],
        "operationId": "getPriser",
        "summary": "Today's and tomorrow's 15-minute prices for one bidding zone",
        "description": "Tomorrow's prices are published around 13:00 Europe/Stockholm; until then `imorgon_publicerat` is false and `serie` holds today only.",
        "parameters": [
          {
            "name": "elomrade",
            "in": "path",
            "required": true,
            "description": "Bidding zone. SE1 Luleå, SE2 Sundsvall, SE3 Stockholm, SE4 Malmö.",
            "schema": {
              "type": "string",
              "enum": [
                "SE1",
                "SE2",
                "SE3",
                "SE4"
              ]
            }
          }
        ],
        "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/Priser"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/OkandNyckel"
          },
          "404": {
            "$ref": "#/components/responses/SaknasEj"
          },
          "429": {
            "$ref": "#/components/responses/Grans"
          },
          "502": {
            "$ref": "#/components/responses/Otillganglig"
          }
        }
      }
    },
    "/v1/elnatsavgifter": {
      "get": {
        "tags": [
          "elnatsavgifter"
        ],
        "operationId": "listElnatsavgifter",
        "summary": "All 188 grid companies with a reference 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/ElnatOversikt"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/OkandNyckel"
          },
          "429": {
            "$ref": "#/components/responses/Grans"
          },
          "502": {
            "$ref": "#/components/responses/Otillganglig"
          }
        }
      }
    },
    "/v1/elnatsavgifter/{slug}": {
      "get": {
        "tags": [
          "elnatsavgifter"
        ],
        "operationId": "getElnatsavgift",
        "summary": "Grid fees for one company, all six standard customers, per year",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "The `slug` field from /v1/elnatsavgifter, e.g. `borlange-energi-elnat`.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Grid fees",
            "headers": {
              "x-ratelimit-limit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "x-ratelimit-remaining": {
                "$ref": "#/components/headers/RateRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Elnatsbolag"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/OkandNyckel"
          },
          "404": {
            "$ref": "#/components/responses/SaknasEj"
          },
          "429": {
            "$ref": "#/components/responses/Grans"
          }
        }
      }
    },
    "/nycklar": {
      "post": {
        "tags": [
          "nycklar"
        ],
        "operationId": "skapaNyckel",
        "summary": "Create an optional key (higher limit). Shown once.",
        "security": [
          {}
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "epost": {
                    "type": "string",
                    "format": "email",
                    "description": "Optional, only used to announce API changes."
                  },
                  "etikett": {
                    "type": "string",
                    "maxLength": 60
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Key created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "nyckel",
                    "skapad",
                    "grans_per_timme"
                  ],
                  "properties": {
                    "nyckel": {
                      "type": "string",
                      "pattern": "^ep_live_[0-9a-f]{32}$"
                    },
                    "skapad": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "epost": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "notis": {
                      "type": "string"
                    },
                    "grans_per_timme": {
                      "type": "integer"
                    },
                    "dokumentation": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/Grans"
          }
        }
      },
      "delete": {
        "tags": [
          "nycklar"
        ],
        "operationId": "taBortNyckel",
        "summary": "Delete your own key",
        "security": [
          {
            "bearerKey": []
          },
          {
            "queryKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "borttagen": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/OkandNyckel"
          }
        }
      }
    },
    "/nycklar/min": {
      "get": {
        "tags": [
          "nycklar"
        ],
        "operationId": "minNyckel",
        "summary": "Look up your own key",
        "security": [
          {
            "bearerKey": []
          },
          {
            "queryKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Key metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "skapad": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "epost": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "etikett": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "grans_per_timme": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/OkandNyckel"
          },
          "404": {
            "$ref": "#/components/responses/SaknasEj"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Optional. Raises the limit to 2000 requests/hour."
      },
      "queryKey": {
        "type": "apiKey",
        "in": "query",
        "name": "nyckel",
        "description": "Optional. Same key as a query parameter (`key` also works)."
      }
    },
    "headers": {
      "RateLimit": {
        "schema": {
          "type": "integer"
        },
        "description": "120 without a key, 2000 with one"
      },
      "RateRemaining": {
        "schema": {
          "type": "integer"
        },
        "description": "Requests left in the current hour"
      }
    },
    "responses": {
      "SaknasEj": {
        "description": "Unknown endpoint or company",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Fel"
            }
          }
        }
      },
      "OkandNyckel": {
        "description": "A key was given but is not known. Remove it or create a new one.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Fel"
            }
          }
        }
      },
      "Grans": {
        "description": "Hourly limit reached",
        "headers": {
          "retry-after": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds until the window resets"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Fel"
            }
          }
        }
      },
      "Otillganglig": {
        "description": "Upstream data temporarily unavailable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Fel"
            }
          }
        }
      }
    },
    "schemas": {
      "Fel": {
        "type": "object",
        "required": [
          "fel"
        ],
        "properties": {
          "fel": {
            "type": "string"
          },
          "tips": {
            "type": "string"
          },
          "dokumentation": {
            "type": "string",
            "format": "uri"
          },
          "grans_per_timme": {
            "type": "integer"
          }
        }
      },
      "Kvart": {
        "type": "object",
        "required": [
          "start",
          "end",
          "pris_ore"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "spot_ore_exkl_moms": {
            "type": "number",
            "description": "Spot price, öre/kWh, excluding VAT"
          },
          "spot_ore_inkl_moms": {
            "type": "number"
          },
          "pris_ore": {
            "type": "number",
            "description": "Spot + energy tax, including VAT – what the household pays for the energy"
          },
          "pris_ore_nedsatt_skatt": {
            "type": "number",
            "description": "Same, with the reduced energy tax of the northern municipalities"
          },
          "imorgon": {
            "type": "boolean"
          }
        }
      },
      "Priser": {
        "type": "object",
        "required": [
          "elomrade",
          "valuta",
          "enhet",
          "serie",
          "genererad"
        ],
        "properties": {
          "elomrade": {
            "type": "string",
            "enum": [
              "SE1",
              "SE2",
              "SE3",
              "SE4"
            ]
          },
          "namn": {
            "type": "string"
          },
          "stad": {
            "type": "string"
          },
          "valuta": {
            "const": "SEK"
          },
          "enhet": {
            "const": "öre/kWh"
          },
          "upplosning": {
            "type": "string",
            "description": "ISO 8601 duration of each entry in `serie` (PT15M)"
          },
          "upplosning_not": {
            "type": "string"
          },
          "moms_procent": {
            "type": "number"
          },
          "energiskatt": {
            "type": "object",
            "properties": {
              "ar": {
                "type": "integer"
              },
              "ore_per_kwh_inkl_moms": {
                "type": "number"
              },
              "nedsatt_ore_per_kwh_inkl_moms": {
                "type": "number"
              },
              "nedsatt_gäller_kommuner": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "not": {
                "type": "string"
              }
            }
          },
          "idag": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "datum": {
                "type": "string",
                "format": "date"
              },
              "antal": {
                "type": "integer",
                "description": "Number of intervals (96 on a normal day)"
              },
              "snitt": {
                "type": "number"
              },
              "min": {
                "type": "object",
                "properties": {
                  "ore": {
                    "type": "number"
                  },
                  "start": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              },
              "max": {
                "type": "object",
                "properties": {
                  "ore": {
                    "type": "number"
                  },
                  "start": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            }
          },
          "imorgon_publicerat": {
            "type": "boolean"
          },
          "serie": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Kvart"
            }
          },
          "kalla": {
            "type": "string"
          },
          "villkor": {
            "type": "string"
          },
          "genererad": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Arsavgift": {
        "type": "object",
        "properties": {
          "fast_kr_per_ar": {
            "type": "number"
          },
          "myndighetsavgift_kr_per_ar": {
            "type": "number"
          },
          "rorlig_ore_per_kwh": {
            "type": "number"
          },
          "totalt_kr_per_ar": {
            "type": "number"
          },
          "totalt_kr_per_ar_inkl_moms": {
            "type": "number"
          }
        }
      },
      "Forandring": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "fran_ar": {
            "type": "string"
          },
          "till_ar": {
            "type": "string"
          },
          "procent": {
            "type": "number"
          }
        }
      },
      "ElnatOversikt": {
        "type": "object",
        "required": [
          "foretag",
          "kalla_hamtad"
        ],
        "properties": {
          "enhet": {
            "type": "string"
          },
          "valuta": {
            "const": "SEK"
          },
          "moms_not": {
            "type": "string"
          },
          "forutsattningar": {
            "type": "object"
          },
          "begransningar": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "antal_foretag": {
            "type": "integer"
          },
          "antal_med_senaste_ar": {
            "type": "integer"
          },
          "senaste_ar": {
            "type": "string"
          },
          "median_referens_kr_per_ar": {
            "type": "number"
          },
          "median_referens_kr_per_ar_inkl_moms": {
            "type": "number"
          },
          "foretag": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "slug",
                "namn"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Ei's company id (REL…)"
                },
                "slug": {
                  "type": "string"
                },
                "namn": {
                  "type": "string"
                },
                "juridiskt_namn": {
                  "type": "string"
                },
                "omrade": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "senaste_ar": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "antal_typkunder": {
                  "type": "integer"
                },
                "referens": {
                  "description": "Reference customer (villa 20 A, 20 000 kWh/yr) for the latest year; null when the company has no figures for it",
                  "anyOf": [
                    {
                      "type": "null"
                    },
                    {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/Arsavgift"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "typkund": {
                              "type": "string"
                            },
                            "ar": {
                              "type": "string"
                            },
                            "forandring": {
                              "$ref": "#/components/schemas/Forandring"
                            }
                          }
                        }
                      ]
                    }
                  ]
                },
                "detalj": {
                  "type": "string",
                  "format": "uri"
                },
                "sida": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "kalla": {
            "type": "string"
          },
          "kalla_url": {
            "type": "string",
            "format": "uri"
          },
          "kalla_hamtad": {
            "type": "string",
            "format": "date"
          },
          "licens": {
            "type": "string"
          },
          "villkor": {
            "type": "string"
          },
          "dokumentation": {
            "type": "string",
            "format": "uri"
          },
          "genererad": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Elnatsbolag": {
        "type": "object",
        "required": [
          "id",
          "slug",
          "namn",
          "typkunder"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "namn": {
            "type": "string"
          },
          "juridiskt_namn": {
            "type": "string"
          },
          "omrade": {
            "type": [
              "string",
              "null"
            ]
          },
          "senaste_ar": {
            "type": [
              "string",
              "null"
            ]
          },
          "enhet": {
            "type": "string"
          },
          "valuta": {
            "const": "SEK"
          },
          "moms_not": {
            "type": "string"
          },
          "mot_median": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "typkund": {
                "type": "string"
              },
              "ar": {
                "type": "string"
              },
              "mitt_kr_per_ar": {
                "type": "number"
              },
              "median_kr_per_ar": {
                "type": "number"
              },
              "skillnad_kr_per_ar": {
                "type": "number"
              },
              "skillnad_kr_per_ar_inkl_moms": {
                "type": "number"
              },
              "skillnad_procent": {
                "type": "number"
              }
            }
          },
          "typkunder": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "typkund": {
                  "type": "string"
                },
                "etikett": {
                  "type": "string"
                },
                "forandring": {
                  "$ref": "#/components/schemas/Forandring"
                },
                "ar": {
                  "type": "object",
                  "description": "Keyed by year",
                  "additionalProperties": {
                    "$ref": "#/components/schemas/Arsavgift"
                  }
                }
              }
            }
          },
          "begransningar": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "oversikt": {
            "type": "string",
            "format": "uri"
          },
          "sida": {
            "type": "string",
            "format": "uri"
          },
          "kalla": {
            "type": "string"
          },
          "kalla_url": {
            "type": "string",
            "format": "uri"
          },
          "kalla_hamtad": {
            "type": "string",
            "format": "date"
          },
          "villkor": {
            "type": "string"
          },
          "genererad": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}
