{
  "openapi": "3.0.3",
  "info": {
    "title": "Słup Energii — publiczne API cen",
    "version": "1.0.0",
    "description": "Ceny hurtowe, bez VAT, dystrybucji i marży. RCE i RDN rozdzielone; bez prognoz i sterowania urządzeniami."
  },
  "servers": [
    {
      "url": "https://www.slupenergii.top"
    }
  ],
  "paths": {
    "/api/v1/prices": {
      "get": {
        "operationId": "getPrices",
        "summary": "Opublikowane ceny wybranej doby",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "schema": {
              "type": "string",
              "default": "today"
            },
            "description": "today, tomorrow lub YYYY-MM-DD od dziś−7 dni do jutra; Europe/Warsaw."
          },
          {
            "name": "market",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "rce",
                "rdn"
              ],
              "default": "rce"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pełne, niepełne lub oczekujące dane; sprawdź status/complete/current.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Prices"
                }
              }
            }
          },
          "400": {
            "description": "Błędne parametry"
          },
          "503": {
            "description": "Źródło niedostępne lub nieprawidłowe dane; current=null"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Interval": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "start",
          "end",
          "price",
          "price_pln_mwh"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "price": {
            "type": "number",
            "description": "Hurtowa cena PLN/kWh; zero i wartości ujemne są prawidłowe."
          },
          "price_pln_mwh": {
            "type": "number"
          }
        }
      },
      "Prices": {
        "type": "object",
        "required": [
          "schema_version",
          "market",
          "date",
          "status",
          "complete",
          "intervals",
          "current",
          "fetched_at",
          "generated_at"
        ],
        "properties": {
          "schema_version": {
            "type": "integer",
            "enum": [
              1
            ]
          },
          "market": {
            "type": "string",
            "enum": [
              "PSE_RCE",
              "TGE_RDN_FIXING_I"
            ]
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "timezone": {
            "type": "string",
            "enum": [
              "Europe/Warsaw"
            ]
          },
          "unit": {
            "type": "string",
            "enum": [
              "PLN/kWh"
            ]
          },
          "currency": {
            "type": "string",
            "enum": [
              "PLN"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "pending",
              "incomplete"
            ]
          },
          "complete": {
            "type": "boolean"
          },
          "forecast": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "vat_included": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "distribution_included": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "is_retail_price": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "count": {
            "type": "integer"
          },
          "expected_count": {
            "type": "integer"
          },
          "published_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "fetched_at": {
            "type": "string",
            "format": "date-time"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "current": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Interval"
              }
            ],
            "nullable": true
          },
          "intervals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Interval"
            }
          },
          "source": {
            "type": "object"
          }
        }
      }
    }
  }
}
