{
  "openapi": "3.1.0",
  "info": {
    "title": "Elkvarten price API",
    "version": "1.1.0",
    "description": "Read-only Swedish electricity spot prices per 15 minutes for the four Swedish bidding zones, for today and (after about 13:00 Swedish time) tomorrow. Prices are in SEK per kWh excluding VAT; multiply by 1.25 for the consumer price including VAT. Energy tax, supplier surcharge and grid fee are not included. All times are Swedish local time with UTC offset."
  },
  "paths": {
    "/api/v1/prices/{zone}": {
      "get": {
        "summary": "Current price, daily statistics and every 15-minute price for one zone",
        "operationId": "getZonePrices",
        "parameters": [
          {
            "name": "zone",
            "in": "path",
            "required": true,
            "description": "Bidding zone: se1 (Luleå), se2 (Sundsvall), se3 (Stockholm) or se4 (Malmö).",
            "schema": {
              "type": "string",
              "enum": [
                "se1",
                "se2",
                "se3",
                "se4"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Prices for the zone.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ZonePrices"
                }
              }
            }
          },
          "404": {
            "description": "Unknown zone."
          },
          "429": {
            "description": "Too many requests from this address."
          },
          "503": {
            "description": "Prices are temporarily unavailable. Retry after the number of seconds in the Retry-After header."
          }
        }
      }
    },
    "/api/v1/plan/{zone}": {
      "get": {
        "summary": "Whether to run a load now, and the cheapest time for it",
        "description": "Made for smart-home systems that poll. The schedule is fixed once per period, so the answer does not change between polls and runNow is true for exactly the requested time. Without \"before\" the period is the calendar day. With it, the period is the 24 hours up to that time; if that time is earlier than 13:00 the period starts at 13:00 the day before, because the night's prices are not published earlier. While the period's prices are not all published, waitingForPrices is true and runNow is false.",
        "operationId": "getZonePlan",
        "parameters": [
          {
            "name": "zone",
            "in": "path",
            "required": true,
            "description": "Bidding zone: se1 (Luleå), se2 (Sundsvall), se3 (Stockholm) or se4 (Malmö).",
            "schema": {
              "type": "string",
              "enum": [
                "se1",
                "se2",
                "se3",
                "se4"
              ]
            }
          },
          {
            "name": "hours",
            "in": "query",
            "description": "How long the load must run. Default 1.",
            "schema": {
              "type": "number",
              "minimum": 0.25,
              "maximum": 24,
              "multipleOf": 0.25,
              "default": 1
            }
          },
          {
            "name": "before",
            "in": "query",
            "description": "Finish by this Swedish local time, on a quarter hour.",
            "schema": {
              "type": "string",
              "pattern": "^([01][0-9]|2[0-3]):(00|15|30|45)$"
            },
            "example": "07:00"
          },
          {
            "name": "split",
            "in": "query",
            "description": "1 when the load can pause and resume; the cheapest separate quarters are then chosen.",
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ]
            }
          },
          {
            "name": "extraOre",
            "in": "query",
            "description": "Household fees in öre per kWh including VAT, added to the totalOrePerKwh values.",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Plan"
                }
              }
            }
          },
          "400": {
            "description": "A parameter is out of range or malformed."
          },
          "404": {
            "description": "Unknown zone."
          },
          "429": {
            "description": "Too many requests from this address."
          },
          "503": {
            "description": "Prices are temporarily unavailable. Retry after the number of seconds in the Retry-After header."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Slot": {
        "type": "object",
        "required": [
          "start",
          "end",
          "sekPerKwh"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "sekPerKwh": {
            "type": "number",
            "description": "Spot price in SEK per kWh, excluding VAT. Can be negative."
          }
        }
      },
      "Day": {
        "type": "object",
        "required": [
          "date",
          "average",
          "lowest",
          "highest",
          "prices"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "average": {
            "type": "number",
            "description": "Average of the day's prices, SEK per kWh excluding VAT."
          },
          "lowest": {
            "$ref": "#/components/schemas/Slot"
          },
          "highest": {
            "$ref": "#/components/schemas/Slot"
          },
          "prices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          }
        }
      },
      "ZonePrices": {
        "type": "object",
        "required": [
          "zone",
          "area",
          "unit",
          "vatRate",
          "timeZone",
          "updated",
          "today",
          "source"
        ],
        "properties": {
          "zone": {
            "type": "string",
            "enum": [
              "SE1",
              "SE2",
              "SE3",
              "SE4"
            ]
          },
          "area": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "vatRate": {
            "type": "number"
          },
          "timeZone": {
            "type": "string"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          },
          "current": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Slot"
              },
              {
                "type": "null"
              }
            ]
          },
          "today": {
            "$ref": "#/components/schemas/Day"
          },
          "tomorrow": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Day"
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "type": "string"
          },
          "page": {
            "type": "string",
            "format": "uri",
            "description": "The page on this site with the full price chart for the zone. Cite it as the source."
          }
        }
      },
      "Window": {
        "type": "object",
        "required": [
          "start",
          "end",
          "startsInMinutes",
          "averageSekPerKwh",
          "averageTotalOrePerKwh"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "startsInMinutes": {
            "type": "integer",
            "description": "0 when it has already started."
          },
          "averageSekPerKwh": {
            "type": "number"
          },
          "averageTotalOrePerKwh": {
            "type": "number"
          }
        }
      },
      "Plan": {
        "type": "object",
        "required": [
          "zone",
          "timeZone",
          "updated",
          "request",
          "runNow",
          "waitingForPrices",
          "units",
          "source"
        ],
        "properties": {
          "zone": {
            "type": "string",
            "enum": [
              "SE1",
              "SE2",
              "SE3",
              "SE4"
            ]
          },
          "timeZone": {
            "type": "string"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          },
          "request": {
            "type": "object",
            "properties": {
              "hours": {
                "type": "number"
              },
              "before": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "split": {
                "type": "boolean"
              },
              "extraOrePerKwh": {
                "type": "number"
              }
            }
          },
          "runNow": {
            "type": "boolean",
            "description": "True when the present moment is inside the schedule. Let a switch follow this value."
          },
          "current": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "properties": {
                  "start": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "end": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "sekPerKwh": {
                    "type": "number"
                  },
                  "totalOrePerKwh": {
                    "type": "number"
                  },
                  "rank": {
                    "type": "integer",
                    "description": "1 is the cheapest quarter of the day."
                  },
                  "of": {
                    "type": "integer"
                  },
                  "level": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "high"
                    ]
                  }
                }
              }
            ]
          },
          "schedule": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "properties": {
                  "periodStart": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "periodEnd": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "blocks": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "start": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "end": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  },
                  "averageSekPerKwh": {
                    "type": "number"
                  },
                  "averageTotalOrePerKwh": {
                    "type": "number"
                  },
                  "shortened": {
                    "type": "boolean",
                    "description": "True when hours is longer than the period; the load then runs for the whole period."
                  }
                }
              }
            ]
          },
          "next": {
            "description": "The scheduled stretch that is running or still to come; null once the last one in the period has passed.",
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Window"
              }
            ]
          },
          "startNow": {
            "description": "For comparison: what one unbroken run started this minute would cost on average. Not given for split loads.",
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Window"
              }
            ]
          },
          "units": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "waitingForPrices": {
            "type": "boolean",
            "description": "True when the period reaches into tomorrow and those prices are not published yet. Nothing is scheduled and runNow is false."
          },
          "page": {
            "type": "string",
            "format": "uri",
            "description": "The page on this site with the full price chart for the zone. Cite it as the source."
          }
        }
      }
    }
  }
}
