{
  "openapi": "3.0.3",
  "info": {
    "title": "Varta read-only API",
    "version": "1.0.0-beta",
    "description": "NEPTUN attribution must remain visible next to data. Informational, potentially delayed data; follow official alerts. Create keys in the authenticated developer dashboard: up to 3 active keys per account, with 7, 30 or 90 day expiry. Keys are shown once and can be revoked. Poll every 30 seconds. Limits: 30 GET requests/min/key for alerts; 120 GET requests/min/IP across all endpoints. CORS permits X-API-Key; keep keys on the server, not in frontend code. Unknown query parameters are rejected. Stale (>90s) or invalid snapshots never return live records. No UAV or missile feed.",
    "contact": {
      "url": "https://kalush-game.life/varta/developers/feedback.html?kind=api"
    }
  },
  "servers": [
    {
      "url": "https://kalush-game.life/varta/api/v1"
    }
  ],
  "paths": {
    "/status": {
      "get": {
        "summary": "Collector freshness, not proof of safety or an independent provider health check.",
        "operationId": "status",
        "security": [],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "400": {
            "description": "invalid_query",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "service_unavailable; alerts may return data_unavailable with status and empty items",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/demo": {
      "get": {
        "summary": "Synthetic example, never live data.",
        "operationId": "demo",
        "security": [],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Demo"
                }
              }
            }
          },
          "400": {
            "description": "invalid_query",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "service_unavailable; alerts may return data_unavailable with status and empty items",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/alerts": {
      "get": {
        "summary": "Current source records, optionally filtered by exact Ukrainian region name.",
        "operationId": "alerts",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Alerts"
                }
              }
            }
          },
          "400": {
            "description": "invalid_query",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "method_not_allowed",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "service_unavailable; alerts may return data_unavailable with status and empty items",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "invalid_api_key",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait on 429/503.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "region",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Exact value of the region field. Omit to return all source records. No match yields an empty list, not an all-clear."
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Status": {
        "type": "object",
        "required": [
          "version",
          "source",
          "notice",
          "refreshSeconds",
          "maxAgeSeconds",
          "status",
          "fetchedAt"
        ],
        "properties": {
          "version": {
            "type": "string",
            "enum": [
              "1"
            ]
          },
          "source": {
            "type": "object",
            "required": [
              "name",
              "url",
              "terms",
              "attributionRequired"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "terms": {
                "type": "string",
                "format": "uri"
              },
              "attributionRequired": {
                "type": "boolean"
              }
            }
          },
          "notice": {
            "type": "string"
          },
          "refreshSeconds": {
            "type": "integer",
            "enum": [
              30
            ]
          },
          "maxAgeSeconds": {
            "type": "integer",
            "enum": [
              90
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "available",
              "unavailable",
              "stale",
              "example"
            ]
          },
          "fetchedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "ageSeconds": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "Alert": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "key",
          "scope",
          "name",
          "region",
          "since",
          "level"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "key": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "enum": [
              "oblast",
              "raion"
            ]
          },
          "name": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "since": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "level": {
            "type": "string",
            "enum": [
              "red",
              "yellow",
              "unknown"
            ]
          }
        }
      },
      "Alerts": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Status"
          },
          {
            "type": "object",
            "required": [
              "region",
              "total",
              "items"
            ],
            "properties": {
              "region": {
                "type": "string",
                "nullable": true
              },
              "total": {
                "type": "integer",
                "minimum": 0
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Alert"
                }
              }
            }
          }
        ]
      },
      "Demo": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Status"
          },
          {
            "type": "object",
            "required": [
              "demo",
              "items"
            ],
            "properties": {
              "demo": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Alert"
                }
              }
            }
          }
        ]
      },
      "Error": {
        "type": "object",
        "required": [
          "version",
          "error"
        ],
        "properties": {
          "version": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "required": [
              "code"
            ],
            "properties": {
              "code": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "url": "https://neptun.in.ua/api-terms",
    "description": "Required source attribution and usage terms"
  }
}
